oven-sh/bun · error · Error

Expected ${expected} to be ${equal} for ${description}

Error message

Expected ${expected} to be ${equal} for ${description}

What it means

Assertion in the deep-equals benchmark fixture runner. Each fixture pair (value1, value2, equal) is run through both Bun.deepEquals and fastDeepEquals; if the returned boolean differs from the fixture's expected `equal` flag, this error names the mismatch. It signals a deep-equality false positive or false negative — or a fixture whose expected flag is wrong.

Source

Thrown at bench/snippets/deep-equals.js:496

            subProp1: "sub value1",
          },
        },
        equal: true,
      },
    ],
  },
];

for (let { tests, description } of fixture) {
  // if (description === "sample objects") {
  for (let { description: describe, value1, value2, equal } of tests) {
    var expected;
    group(describe, () => {
      for (let equalsFn of [Bun.deepEquals, fastDeepEquals]) {
        bench(`${describe}: ${equalsFn.name}`, () => {
          expected = equalsFn(value1, value2);
          if (expected !== equal) {
            throw new Error(`Expected ${expected} to be ${equal} for ${description}`);
          }
        });
      }
    });
    // }
  }
}

await run();

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Read the error to get `description` (fixture group) and the bench group name printed around it to identify the exact pair
  2. Extract that pair into a small script and compare against Node's ground truth: util.isDeepStrictEqual(value1, value2)
  3. If Node agrees with the fixture, fix the Bun.deepEquals branch that mishandles the case; if Node disagrees, correct the fixture's `equal` flag
  4. Re-run the bench to confirm all fixture pairs pass

Example fix

// before (fixture claims unequal, Bun.deepEquals returns true)
{ value1: objA, value2: objB, equal: false }
// after (verify ground truth first, then align)
const { isDeepStrictEqual } = require('node:util');
console.log(isDeepStrictEqual(objA, objB)); // set fixture `equal` to this result
Defensive patterns

Strategy: validation

Validate before calling

// before adding a fixture pair, pin ground truth with Node
const { isDeepStrictEqual } = require('node:util');
// equal: isDeepStrictEqual(value1, value2)  <- use this result

Try / catch

// keep the bench's failure informative
try {
  const got = equalsFn(value1, value2);
  if (got !== equal) console.error(`${equalsFn.name} said ${got}, expected ${equal} for ${describe}`);
} catch (e) {
  console.error(`${equalsFn.name} threw on ${describe}:`, e);
}

Prevention

When it happens

Trigger: Executing bench/snippets/deep-equals.js and hitting a fixture pair whose semantics are subtle: typed arrays, boxed primitives, NaN/-0, prototypes, getters, Symbol keys, sparse arrays, cross-realm objects — cases where Bun.deepEquals disagrees with the fixture's ground truth.

Common situations: A change to Bun.deepEquals breaking a corner case; adding a new fixture entry with an incorrect `equal` value; upgrading the fast-deep-equal dependency so the two implementations diverge on a fixture.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/3b74d24e14c7e977. Report an issue: GitHub.