Skip to content

withArgs stops matching Buffers by content in 21.0.2 (samsam major bump in patch release) #2678

@marie-bisault

Description

@marie-bisault

Describe the bug

stub.withArgs() no longer matches Buffer arguments by content when called with a different reference holding the same bytes. This regression was introduced in 21.0.2.

To Reproduce

const sinon = require('sinon')

const buf1 = Buffer.from([255, 216, 255, 224])
const buf2 = Buffer.from([255, 216, 255, 224]) // same content, different reference

const stub = sinon.stub()
stub.withArgs({ buffer: buf1 }).returns('ok')

console.log(stub({ buffer: buf2 }))
// sinon@21.0.1 → 'ok'
// sinon@21.0.2 → undefined

Expected behavior
withArgs should match Buffer instances with equal content, as it did in 21.0.1.

Screenshots
N/A

Context:

  • Sinon version: 21.0.2 (broken), verified working on 21.0.1
  • Runtime: Node 22.14.0
  • Output of npx envinfo --browsers --binaries:
  Binaries:
    Node: 22.14.0 - /usr/local/.nvm/versions/node/v22.14.0/bin/node
    Yarn: 4.9.2 - /usr/local/.nvm/versions/node/v22.14.0/bin/yarn
    npm: 10.9.2 - /usr/local/.nvm/versions/node/v22.14.0/bin/npm
    bun: 1.2.23 - /usr/local/.bun/bin/bun
  Browsers:
    Chrome: 145.0.7632.159
    Firefox: 148.0
    Firefox Developer Edition: 148.0
  • Other relevant environmental info: the root cause is a dependency bump in sinon's own package.json between 21.0.1 and 21.0.2:
    21.0.1 → "@sinonjs/samsam": "^8.0.3"
    21.0.2 → "@sinonjs/samsam": "^9.0.2"
  • A major samsam version was introduced in a patch sinon release, which violates semver and silently breaks any project using "sinon": "^21.0.0" on the next install.
  • Other libraries you are using: none required to reproduce
  • Example URL: N/A

Additional context:
Suggested fix: revert the samsam bump in a 21.0.3 patch, or re-release with a minor/major version bump to properly signal the breaking change.

Workaround in the meantime: pin sinon to 21.0.1.

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