Skip to content

bun test --isolate: opt-in global reuse fast path - #36871

Open
robobun wants to merge 11 commits into
mainfrom
farm/490b3121/isolate-fast-reset
Open

bun test --isolate: opt-in global reuse fast path#36871
robobun wants to merge 11 commits into
mainfrom
farm/490b3121/isolate-fast-reset

reset overridenDateNow + process listeners; resetSpies before pristin…

c36cf41
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 4, 2026 in 22m 44s

Code review found 1 important issue

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

Details

Severity Count
🔴 Important 1
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/jsc/bindings/ZigGlobalObject.cpp:760-775 Re-capture after reuse folds surviving node_modules into preloadModuleKeys
🟡 Nit src/jsc/bindings/ZigGlobalObject.cpp:908-912 process.setUncaughtExceptionCaptureCallback state survives reuse

Annotations

Check failure on line 775 in src/jsc/bindings/ZigGlobalObject.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

Re-capture after reuse folds surviving node_modules into preloadModuleKeys

Re-capturing the baseline on a reused global (c36cf411's `baseline_captured = false`) folds surviving node_modules into `preloadModuleKeys`: at re-capture time the moduleMap still contains every node_modules record the previous reset kept, and this loop snapshots the entire map, so on the *next* reset `shouldEvict` returns true for them and they're dropped. A node_modules dep loaded by file N survives into N+1 (one hit) then is evicted before N+2, alternating hit/miss thereafter — directly contr

Check warning on line 912 in src/jsc/bindings/ZigGlobalObject.cpp

See this annotation in the file changed.

@claude claude / Claude Code Review

process.setUncaughtExceptionCaptureCallback state survives reuse

The `hasProcessObject()` reset block clears listeners and `m_cachedCwd` but leaves `m_uncaughtExceptionCaptureCallback` / `m_reportOnUncaughtException` untouched, so a file (or preload) that calls `process.setUncaughtExceptionCaptureCallback(fn)` causes the next reused file's call to throw `ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET` (BunProcess.cpp:907). Same native-per-object-field class as `overridenDateNow` and `m_cachedCwd` already fixed in this block; add `process->setUncaughtExceptionCapt