From 05e7af40cbcd03ea32720f05efad76f0db33634d Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Fri, 17 Jul 2026 13:46:15 -0700 Subject: [PATCH] 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 " 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). --- test/unit/miner-extension-live-fetch.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/unit/miner-extension-live-fetch.test.ts b/test/unit/miner-extension-live-fetch.test.ts index 4202ec28e5..8c9039567c 100644 --- a/test/unit/miner-extension-live-fetch.test.ts +++ b/test/unit/miner-extension-live-fetch.test.ts @@ -75,6 +75,13 @@ function loadBackgroundWithFakeChrome({ __LOOPOVER_MINER_EXTENSION_TEST__: true, chrome, fetch: fetchImpl, + // 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), so the sandbox + // needs both real globals injected or those calls throw " is not defined" on any payload that + // reaches the success path. + AbortSignal, + TextEncoder, }; context.globalThis = context; const vmContext = createContext(context);