Skip to content

Quality: Global mutable call id can grow unbounded across long-lived processes#2691

Merged
fatso83 merged 2 commits into
sinonjs:mainfrom
tuanaiseo:contribai/improve/quality/global-mutable-call-id-can-grow-unbounde
May 5, 2026
Merged

Quality: Global mutable call id can grow unbounded across long-lived processes#2691
fatso83 merged 2 commits into
sinonjs:mainfrom
tuanaiseo:contribai/improve/quality/global-mutable-call-id-can-grow-unbounde

Conversation

@tuanaiseo

Copy link
Copy Markdown
Contributor

Problem

callId is module-scoped and incremented on every invocation. In long-running test runners or embedded usage, this can grow indefinitely and eventually lose integer precision semantics for strict ordering comparisons.

Severity: low
File: lib/sinon/proxy-invoke.js

Solution

Reset or wrap callId safely (e.g., modulo Number.MAX_SAFE_INTEGER) and document ordering guarantees when rollover occurs.

Changes

  • lib/sinon/proxy-invoke.js (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

fatso83
fatso83 previously requested changes Apr 9, 2026

@fatso83 fatso83 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing! Just a minor note.

Comment thread src/sinon/proxy-invoke.js Outdated
@fatso83

fatso83 commented May 5, 2026

Copy link
Copy Markdown
Contributor

can you please rebase and add a test?

`callId` is module-scoped and incremented on every invocation. In long-running test runners or embedded usage, this can grow indefinitely and eventually lose integer precision semantics for strict ordering comparisons.

Affected files: proxy-invoke.js

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
@fatso83 fatso83 force-pushed the contribai/improve/quality/global-mutable-call-id-can-grow-unbounde branch from 9de5650 to c01a280 Compare May 5, 2026 20:22
@fatso83 fatso83 dismissed their stale review May 5, 2026 20:27

addressed

@fatso83 fatso83 merged commit 0536afc into sinonjs:main May 5, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants