Skip to content

Normalize scope-object this in mock function calls to prevent leak/crash - #31605

Closed
robobun wants to merge 2 commits into
mainfrom
farm/898354b3/fix-mock-returnthis-scope-leak
Closed

Normalize scope-object this in mock function calls to prevent leak/crash#31605
robobun wants to merge 2 commits into
mainfrom
farm/898354b3/fix-mock-returnthis-scope-leak

ci: retrigger

009d791
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed May 30, 2026 in 21m 11s

Code review found 1 potential issue

Found 1 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 0
🟣 Pre-existing 1
Severity File:Line Issue
🟣 Pre-existing src/jsc/bindings/JSMockFunction.cpp:845 Same scope-object leak remains in JSMock__jsSetSystemTime

Annotations

Check notice on line 845 in src/jsc/bindings/JSMockFunction.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

Same scope-object leak remains in JSMock__jsSetSystemTime

Pre-existing: the same raw `callframe->thisValue()` leak fixed here is still present ~600 lines down in `JSMock__jsSetSystemTime` (returns `JSValue::encode(callframe->thisValue())` on both paths, lines ~1462/1467) and in `JSMock__jsUseRealTimers` (~1435). `setSystemTime` is exposed as a top-level `bun:test` export (jest.zig:224-225), so `const { setSystemTime } = require("bun:test"); const c = () => setSystemTime; typeof setSystemTime(0) === "function"` reproduces the same JSLexicalEnvironment l