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-6249): prevent make invocation on falsy responseType #4167

Closed
wants to merge 2 commits into from

Conversation

fredmaggiowski
Copy link

@fredmaggiowski fredmaggiowski commented Jul 2, 2024

Description

By NODE-6249 we are receiving a TypeError in the changeStream.on('error') handler:

TypeError: responseType ?? responses_1.MongoDBResponse).make is not a function

This TypeError can occur either because:

  • responseType is falsy (but not nullish); or
  • an unexpected responseType that doesn't fit the MongoDBResponseConstructor type is received

What is changing?

This PR proposes a change that makes the (responseType/MongoDBResponse).make() more robust, by falling-back to MongoDBResponse on all the falsy values rather than only the nullish ones.

Is there new documentation needed for these changes?

don't think so

What is the motivation for this change?

As said above, we are receiving a TypeError that feels a lot like a programming error; this may help mitigate the issue; I couldn't find a way (if given some help/insight I can try and further investigate) to understand the actual value for responseType.

Release Highlight

Fixed change stream cursor error bug that may result in receiving a TypeError

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

@fredmaggiowski fredmaggiowski marked this pull request as draft July 3, 2024 10:08
@fredmaggiowski
Copy link
Author

fredmaggiowski commented Jul 4, 2024

I found out the issue was related to an incompatibility between mongodb driver 6.8.0 and @opentelemetry/instrumentation-mongodb <0.46.0: open-telemetry/opentelemetry-js-contrib#2314

Updating the latter, the bug stopped happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant