Skip to content

Commit 05e7af4

Browse files
committed
fix(test): inject AbortSignal/TextEncoder into the miner-extension-live-fetch vm sandbox
node:vm's createContext() is a fresh, isolated realm with none of the outer process's globals. background.js's live-fetch path bounds its fetch with AbortSignal.timeout(...) (#4c0b19f4) and measures the real serialized byte size via TextEncoder for the quota guard (#7062), but the test harness never injected either global into the sandbox -- every call on the success path threw "<Global> is not defined", caught by the function's own try/catch and silently misreported as a typed failure result instead of a real one. Confirmed this isn't CI flakiness: reproduced deterministically outside CI, on every run, for any candidates payload that reaches the success path (all 4 of the 7 originally-failing tests exercise that path; the other 3 return early on a non-2xx/malformed/thrown-fetch branch before ever touching either global).
1 parent 0a2484f commit 05e7af4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

test/unit/miner-extension-live-fetch.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ function loadBackgroundWithFakeChrome({
7575
__LOOPOVER_MINER_EXTENSION_TEST__: true,
7676
chrome,
7777
fetch: fetchImpl,
78+
// node:vm's createContext() is a fresh, isolated realm with none of the outer process's globals --
79+
// background.js's live-fetch path bounds its fetch with AbortSignal.timeout(...) (#4c0b19f4) and
80+
// measures the real serialized byte size via TextEncoder for the quota guard (#7062), so the sandbox
81+
// needs both real globals injected or those calls throw "<Global> is not defined" on any payload that
82+
// reaches the success path.
83+
AbortSignal,
84+
TextEncoder,
7885
};
7986
context.globalThis = context;
8087
const vmContext = createContext(context);

0 commit comments

Comments
 (0)