From 104dac79ccd0014549374fba5f0bcbb18353bd83 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 4 Mar 2021 17:46:40 +0100 Subject: [PATCH] lib: aggregate errors to avoid error swallowing Uses `AggregateError` if there are more than one error with the message of the outer error to preserve the current behaviour, or returns the logical OR comparison of the two parameters. PR-URL: https://github.com/nodejs/node/pull/37460 Reviewed-By: Darshan Sen Reviewed-By: Matteo Collina Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Robert Nagy --- doc/api/fs.md | 24 ++++++-- lib/fs.js | 16 ++--- lib/internal/errors.js | 21 +++++++ lib/internal/fs/read_file_context.js | 3 +- lib/internal/http2/core.js | 3 +- lib/internal/per_context/primordials.js | 1 + lib/internal/streams/destroy.js | 9 ++- test/message/error_aggregateTwoErrors.js | 13 ++++ test/message/error_aggregateTwoErrors.out | 13 ++++ .../parallel/test-error-aggregateTwoErrors.js | 59 +++++++++++++++++++ tools/doc/type-parser.js | 2 +- 11 files changed, 147 insertions(+), 17 deletions(-) create mode 100644 test/message/error_aggregateTwoErrors.js create mode 100644 test/message/error_aggregateTwoErrors.out create mode 100644 test/parallel/test-error-aggregateTwoErrors.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 2a6ca89873ec83..5ffd9df27451a4 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2336,6 +2336,10 @@ error `UV_ENOSYS`.