Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-6763): pass WriteConcernOptions instead on WriteConcernSettings #4421

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stepanho
Copy link

@stepanho stepanho commented Feb 16, 2025

Description

That PR should fix case of loosing write-concern options while using timeoutMS option.
WriteConcern.fromOptions static method accepts 3 options formats:

  • WriteConcernOptions object
  • WriteConcern instance
  • W type

But in case of using timeoutMS options, utils function resolveOptions calls (link to code) WriteConcern.fromOptions with options, which looks like WriteConcern instance, but there is no instance and more look like WriteConcernSettings type:

        writeConcern = WriteConcern.fromOptions({
          ...writeConcern,
          wtimeout: undefined,
          wtimeoutMS: undefined
        });

So that call return undefined as "parsing failed" and command losses write-concern context.

What is changing?

I changed options format to be consistent with WriteConcern.fromOptions type and use WriteConcernOptions format.

Is there new documentation needed for these changes?

No.

What is the motivation for this change?

It's a probably bug.

I used mongodb driver within mongoose and find out updateMany command with writeConcern and timeoutMS options does not pass write-concern context to CommanStartedEvent. This small fix should be helpful.

Release Highlight

Fill in title or leave empty for no highlight

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@stepanho stepanho requested a review from a team as a code owner February 16, 2025 12:31
@stepanho stepanho changed the title fix(NODE-6763): Pass WriteConcernOptions instead on WriteConcernSettings fix(NODE-6763): pass WriteConcernOptions instead on WriteConcernSettings Feb 16, 2025
@dariakp dariakp added tracked-in-jira Ticket filed in MongoDB's Jira system External Submission PR submitted from outside the team labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Submission PR submitted from outside the team tracked-in-jira Ticket filed in MongoDB's Jira system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants