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

XMLWordPrintableJSON

    • 3
    • Not Needed
    • 🔵 Done
    • 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.
    • Not Needed
    • 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:
            Pavel Safronov
            Reporter:
            Alex Bevilacqua
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: