Wrap socket write in a try/catch to ensure errors can be properly wrapped

XMLWordPrintableJSON

    • 3
    • None
    • Hide

      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.

      Show
      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      As described in https://www.mongodb.com/community/forums/t/mongodb-node-js-driver-vs-aws-lambda-with-provisioned-concurrency/326386, a Node.js writeAfterFIN error can bubble up to the driver.

      In NODE-6864, all socket errors were handled to be wrapped in MongoNetworkErrors, however this doesn't appear to be handled. 

      Use Case

      As a... Node.js engineer
      I want... any socket error to be converted to a MongoNetworkError
      So that... driver retry and resume logic responds as expected

      User Experience

      • What is the desired/expected outcome for the user once this ticket is implemented?
        • Socket error events are always converted to our MongoNetworkError class, because the driver will not retry plain runtime errors

      Dependencies

      • None

      Risks/Unknowns

      • What could go wrong while implementing this change? (e.g., performance, inadvertent behavioral changes in adjacent functionality, existing tech debt, etc)
      • Is there an opportunity for better cross-driver alignment or testing in this area?
      • Is there an opportunity to improve existing documentation on this subject?

      Acceptance Criteria

      Implementation Requirements

      • Identify the node socket APIs that are still not being wrapped (socket.write is one)
      • Convert socket errors to MongoNetworkErrors

      Testing Requirements

      • Assert a MongoNetworkError is thrown in the identified cases

      Documentation Requirements

      • None

      Follow Up Requirements

      • None

            Assignee:
            Unassigned
            Reporter:
            Alex Bevilacqua
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: