Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/jsc/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,17 @@ std::optional<bool> specialObjectsDequal(JSC::JSGlobalObject* globalObject, Mark
return false;
}

const PropertyName errors(vm.propertyNames->errors);
auto leftErrors = left->get(globalObject, errors);
RETURN_IF_EXCEPTION(scope, {});
auto rightErrors = right->get(globalObject, errors);
RETURN_IF_EXCEPTION(scope, {});
bool errorsEqual = Bun__deepEquals<isStrict, enableAsymmetricMatchers, skipPrototype>(globalObject, leftErrors, rightErrors, gcBuffer, stack, scope, true);
RETURN_IF_EXCEPTION(scope, {});
if (!errorsEqual) {
return false;
}

// check arbitrary enumerable properties. `.stack` is not checked.
left->materializeErrorInfoIfNeeded(vm);
RETURN_IF_EXCEPTION(scope, {});
Expand Down
35 changes: 35 additions & 0 deletions test/js/node/assert/deep-equal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,41 @@ const cases: Case[] = [
strict: false,
loose: false,
},
{
name: "AggregateError with deep-equal errors",
a: () => new AggregateError([new TypeError("x")], "agg"),
b: () => new AggregateError([new TypeError("x")], "agg"),
strict: true,
loose: true,
},
{
name: "AggregateError with different inner errors",
a: () => new AggregateError([new Error("x")], "agg"),
b: () => new AggregateError([new Error("y")], "agg"),
strict: false,
loose: false,
},
{
name: "AggregateError with different error counts",
a: () => new AggregateError([new Error("x")], "agg"),
b: () => new AggregateError([new Error("x"), new Error("x")], "agg"),
strict: false,
loose: false,
},
{
name: "AggregateError vs plain Error with same message",
a: () => new AggregateError([], "x"),
b: () => new Error("x"),
strict: false,
loose: false,
},
{
name: "Error with non-enumerable own errors vs Error without",
a: () => Object.defineProperty(new Error("x"), "errors", { value: [1], enumerable: false, configurable: true }),
b: () => new Error("x"),
strict: false,
loose: false,
},

// Map and Set.
{
Expand Down
Loading