-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Closed
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.
Description
Version
v20.18.0
Platform
Linux myhostname 6.10.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
assert.deepStrictEqual(new Error("a", { cause: new Error("x") }), new Error("a", { cause: new Error("y") }))
Uncaught:
AssertionError [ERR_ASSERTION]: Values have same structure but are not reference-equal:
[Error: a]
at REPL3:1:8
at ContextifyScript.runInThisContext (node:vm:137:12)
at REPLServer.defaultEval (node:repl:598:22)
at bound (node:domain:432:15)
at REPLServer.runBound [as eval] (node:domain:443:12)
at REPLServer.onLine (node:repl:927:10)
at REPLServer.emit (node:events:531:35)
at REPLServer.emit (node:domain:488:12)
at [_onLine] [as _onLine] (node:internal/readline/interface:417:12)
at [_line] [as _line] (node:internal/readline/interface:888:18) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: [Error: a],
expected: [Error: a],
operator: 'deepStrictEqual'
}
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
I'm not sure what exactly "reference-equal" means, but it sounds like it's about object identity and that might be misleading/bug.
Also ideally it would be nice if assertion diff can show the diff coming from Error.cause
.
What do you see instead?
Assertion error doesn't indicate the error is due to non-matching Error.cause
:
Uncaught:
AssertionError [ERR_ASSERTION]: Values have same structure but are not reference-equal:
[Error: a]
Additional information
I saw Node has expanded on Error
instance deep equality check #51805 and was testing it around. Vitest is trying to catch up in vitest-dev/vitest#5876 and I thought it would be a good reference to know how Node would handle this.
Metadata
Metadata
Assignees
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.