Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5568

Use AggregateErrors to return multiple errors when multiple errors are possible

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Error

      How are you using Mongo? What version of the server and driver are you using?

      As a driver engineer and user,
      I want to receive actionable errors detailing all relevant information,
      So that I can debug the driver and handle errors.

      Relevant to all V6+ drivers.

      What is the feature/improvement you would like?

      There are scenarios when closing async resources where we can have multiple errors. For example, when closing a client with auto encryption enabled, we first teardown the auto encrypter and then teardown the internal client. Both operations can potentially throw.

      Now that Node16 is our minimum supported Node version, we can consider throwing AggregateErrors (or an error that implements this interface - we can't use multiple inheritance in the JS so we can't subclass both Error and AggregateError) so that all relevant errors can be returned to the user. `cause` is not the correct approach here because one error doesn't cause another.

      What use case would this feature/improvement enable?

      Easier debugging and better error reporting in edge cases to users. Additionally, we have a number of cases in our cursors where we intentionally swallow errors from `killCursors` or similar operations, which has led to difficulties debugging in the past because we have no way of knowing if they do throw.

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: