Skip to content

deepEqual is not matching Buffer objects since v9 #289

Closed

Description

@mattbaileyuk

Since @sinonjs/samsam 9.0.0 came out the deepEqual() function is not matching on Buffer objects.

e.g.

const deepEqual = require("@sinonjs/samsam").deepEqual
const buffer1 = Buffer.from("Hello")
const buffer2 = Buffer.from("Hello")
console.log(deepEqual(buffer1, buffer2))

In 8.0.3 this printed true but in 9.0.0 and later this returns false. As sequences of bytes I believe they should identical.

This is impacting sinon when it is doing matching with Buffers since 21.0.2 picked up 9.0.2 of samsam.

Activity

  1. fatso83 commented on Mar 16, 2026

    @fatso83
    Contributor

    Hmm ... wondering which change introduced this. In the list of commits between 8 and 9 I can really only see this as possibly affecting it: #251

  2. fatso83 commented on Mar 16, 2026

    @fatso83
    Contributor

    OK, ran git bisect and found the culprit:

    $ git bisect bad
    
    $ git checkout v8.0.0
    
    $ node test.js
    
    $ git bisect good
    
    $ git bisect run node test.js
    ...
    
    Node.js v24.8.0
    Bisecting: 1 revision left to test after this (roughly 1 step)
    [08ab1b555169c88776f1b7e09c0347604fc91b87] Update eslint-config to include ES2024
    running 'node' 'test.js'
    Bisecting: 0 revisions left to test after this (roughly 0 steps)
    [61cf8ba8a80a775828abb64954bc491da8ae97e8] Bump lint-staged from 16.1.4 to 16.1.5 (#266)
    running 'node' 'test.js'
    3fbe355d19bdaf9be1d5911dde8619eedac3a99e is the first bad commit
    commit 3fbe355d19bdaf9be1d5911dde8619eedac3a99e
    Author: Carl-Erik Kopseng <carlerik@gmail.com>
    Date:   Sun Aug 10 17:45:10 2025 +0200
    
        fix #251: compare props on the prototype chain (#267)
    
        * fix #251: compare enumerable props on the prototype
    
        * Negate test: Arguments with same contents as an array is deeply equal
    
        Co-authored-by: Morgan Roderick <20321+mroderick@users.noreply.github.com>
    
        ---------
    
        Co-authored-by: Morgan Roderick <20321+mroderick@users.noreply.github.com>
    
     lib/deep-equal.js      | 41 ++++++++++++++++++++++++++---------------
     lib/deep-equal.test.js | 27 ++++++++++++++++++++++++++-
     2 files changed, 52 insertions(+), 16 deletions(-)
    bisect found first bad commit
    

    Used your test:

    $ cat test.js
    const deepEqual = require("./lib/deep-equal")
    const assert = require("node:assert")
    const buffer1 = Buffer.from("Hello")
    const buffer2 = Buffer.from("Hello")
    assert(deepEqual(buffer1, buffer2))
    
  3. fatso83 commented on Mar 16, 2026

    @fatso83
    Contributor

    Fixing this now

  4. fatso83 commented on Mar 16, 2026

    @fatso83
    Contributor

    fixed in #291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions