Repository navigation
inspect: print individual AggregateError.errors #43645
Copy link
Copy link
Closed
Labels
errorsIssues and PRs related to JavaScript errors originating in Node.js core.Issues and PRs related to JavaScript errors originating in Node.js core.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.inspectorIssues and PRs related to the V8 inspector protocol.Issues and PRs related to the V8 inspector protocol.
Description
Activity
- addedfeature requestIssues requesting new Node.js features.Issues requesting new Node.js features.inspectorIssues and PRs related to the V8 inspector protocol.Issues and PRs related to the V8 inspector protocol.errorsIssues and PRs related to JavaScript errors originating in Node.js core.Issues and PRs related to JavaScript errors originating in Node.js core.
on Jul 1, 2022 - added a commit that references this issue
on Jul 9, 2022 - added a commit that references this issue
on Jul 12, 2022 - added a commit that references this issue
on Jul 31, 2022 Would it be possible to make this nested/recurse?
(()=>{throw new AggregateError([new AggregateError([new TypeError('blep'), new RangeError('blop')], 'inner')],'gwak')})() Uncaught AggregateError: gwak at REPL2:1:13 { [errors]: [ AggregateError: inner at REPL2:1:33 at REPL2:1:120 at Script.runInThisContext (node:vm:129:12) at REPLServer.defaultEval (node:repl:572:29) at bound (node:domain:433:15) at REPLServer.runBound [as eval] (node:domain:444:12) at REPLServer.onLine (node:repl:902:10) at REPLServer.emit (node:events:525:35) at REPLServer.emit (node:domain:489:12) at REPLServer.Interface._onLine (node:readline:491:10) { [errors]: [Array] } ] }
Notice
[errors]: [Array]This is recursive, but the depth is limited by default.
> [[[123]]] [ [ [ 123 ] ] ] > [[[[123]]]] [ [ [ [Array] ] ] ]
Inspecting explicitly:
> try { (()=>{throw new AggregateError([new AggregateError([new TypeError('blep'), new RangeError('blop')], 'inner')],'gwak')})() } catch(e) { console.log(util.inspect(e)) } AggregateError: gwak at REPL34:1:19 at REPL34:1:126 at Script.runInThisContext (node:vm:129:12) at REPLServer.defaultEval (node:repl:572:29) at bound (node:domain:433:15) at REPLServer.runBound [as eval] (node:domain:444:12) at REPLServer.onLine (node:repl:902:10) at REPLServer.emit (node:events:525:35) at REPLServer.emit (node:domain:489:12) at [_onLine] [as _onLine] (node:internal/readline/interface:425:12) { [errors]: [ AggregateError: inner at REPL34:1:39 at REPL34:1:126 at Script.runInThisContext (node:vm:129:12) at REPLServer.defaultEval (node:repl:572:29) at bound (node:domain:433:15) at REPLServer.runBound [as eval] (node:domain:444:12) at REPLServer.onLine (node:repl:902:10) at REPLServer.emit (node:events:525:35) at REPLServer.emit (node:domain:489:12) at [_onLine] [as _onLine] (node:internal/readline/interface:425:12) { [errors]: [Array] } ] }
Inspecting with
depth: 9:> try { (()=>{throw new AggregateError([new AggregateError([new TypeError('blep'), new RangeError('blop')], 'inner')],'gwak')})() } catch(e) { console.log(util.inspect(e, { depth: 9 })) } AggregateError: gwak at REPL37:1:19 at REPL37:1:126 at Script.runInThisContext (node:vm:129:12) at REPLServer.defaultEval (node:repl:572:29) at bound (node:domain:433:15) at REPLServer.runBound [as eval] (node:domain:444:12) at REPLServer.onLine (node:repl:902:10) at REPLServer.emit (node:events:525:35) at REPLServer.emit (node:domain:489:12) at [_onLine] [as _onLine] (node:internal/readline/interface:425:12) { [errors]: [ AggregateError: inner at REPL37:1:39 at REPL37:1:126 at Script.runInThisContext (node:vm:129:12) at REPLServer.defaultEval (node:repl:572:29) at bound (node:domain:433:15) at REPLServer.runBound [as eval] (node:domain:444:12) at REPLServer.onLine (node:repl:902:10) at REPLServer.emit (node:events:525:35) at REPLServer.emit (node:domain:489:12) at [_onLine] [as _onLine] (node:internal/readline/interface:425:12) { [errors]: [ TypeError: blep at REPL37:1:59 at REPL37:1:126 at Script.runInThisContext (node:vm:129:12) at REPLServer.defaultEval (node:repl:572:29) at bound (node:domain:433:15) at REPLServer.runBound [as eval] (node:domain:444:12) at REPLServer.onLine (node:repl:902:10) at REPLServer.emit (node:events:525:35) at REPLServer.emit (node:domain:489:12) at [_onLine] [as _onLine] (node:internal/readline/interface:425:12), RangeError: blop at REPL37:1:82 at REPL37:1:126 at Script.runInThisContext (node:vm:129:12) at REPLServer.defaultEval (node:repl:572:29) at bound (node:domain:433:15) at REPLServer.runBound [as eval] (node:domain:444:12) at REPLServer.onLine (node:repl:902:10) at REPLServer.emit (node:events:525:35) at REPLServer.emit (node:domain:489:12) at [_onLine] [as _onLine] (node:internal/readline/interface:425:12) ] } ] }
Right, my point was more if it could work by default for
console.logetc without thedepthargument?Reacted by fregante- added a commit that references this issue
on Oct 10, 2022
Metadata
Metadata
Assignees
Labels
errorsIssues and PRs related to JavaScript errors originating in Node.js core.Issues and PRs related to JavaScript errors originating in Node.js core.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.inspectorIssues and PRs related to the V8 inspector protocol.Issues and PRs related to the V8 inspector protocol.
What is the problem this feature will solve?
When
AggregateErroris uncaught or inspected byutil.inspect(), itserrorsproperty is ignored, so all individual errors are being swallowed. We can't get information about what exactly happened, where it happened, even how many errors there were.What is the feature you are proposing to solve the problem?
Printing all
.errorswith their respective stacktraces, either adding it toAggregateErrorinfo or replacing it.What alternatives have you considered?
Abbreviated output, something like
AggregateError[ TypeError, TypeError, EvalError ]. This still doesn't provide enough info: each aggregated error is an uncaught exception/rejection, and debug info should provide as much details as possible about them.