Skip to content

Bug in buffers comparison #2677

Closed
Closed

Description

@rlsf

Describe the bug
we noticed a regression in buffer comparison with the release of sinon 21.0.2
we have a test that started failing with the new release.
i've created a very simple standalone test that recreates it.

To Reproduce
the following test code snippet fails although it should succeed:

describe('test buffer', () => {
  const func = (buffer) => {}
  const key = 'key'
  it.only('matches expected buffer', () => {
    const spy = sinon.spy(func)
    const buffer = Buffer.from(key, 'base64')
    spy(buffer)
    console.log('spy called with: ', spy.getCall(0).args[0])
    console.log('buffer from key: ', Buffer.from(key, 'base64'))
    assert.deepEqual(Buffer.from(key, 'base64'), spy.getCall(0).args[0])
    sinon.assert.calledOnceWithExactly(spy, Buffer.from(key, 'base64'))
  })
})

test buffer
       matches expected buffer:
     AssertError: expected func to be called once and with exact arguments 
<Buffer 91 ec>

Expected behavior
succeed in comparing buffer arguments

Screenshots
N/A

Context (please complete the following information):

  • Sinon version : 21.0.2
  • Runtime: Node v24.13.1
  • Output of npx envinfo --browsers --binaries:
  Binaries:
    Node: 24.13.1 - /usr/local/bin/node
    npm: 11.8.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 145.0.7632.119
    Safari: 26.1

Activity

  1. dhensby commented on Mar 16, 2026

    @dhensby

    Also experienced this regression 21.0.1 works as expected, 21.0.2 breaks.

  2. dhensby commented on Mar 16, 2026

    @dhensby

    Looks like this could be the fix: sinonjs/samsam#291

  3. fatso83 commented on Mar 16, 2026

    @fatso83
    Contributor

    Duplicate of #2678. Fix is out

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions