-
Type: Improvement
-
Resolution: Unresolved
-
Priority: 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.