Skip to content

fix(test): inject AbortSignal/TextEncoder into miner-extension-live-fetch vm sandbox#7092

Merged
JSONbored merged 1 commit into
mainfrom
fix/miner-extension-abortsignal-test-harness
Jul 17, 2026
Merged

fix(test): inject AbortSignal/TextEncoder into miner-extension-live-fetch vm sandbox#7092
JSONbored merged 1 commit into
mainfrom
fix/miner-extension-abortsignal-test-harness

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • `main`'s CI is currently broken: any PR touching `test/unit/miner-extension-live-fetch.test.ts` (which is most PRs, since it's part of the required test suite) fails on 4-7 tests depending on which code path they exercise. Confirmed live blocking a real, unrelated release-please PR (chore(release): cut engine v3.2.1 #7058, engine v3.2.1).
  • Root cause: `node:vm`'s `createContext()` is a fresh, isolated realm with none of the outer process's globals. Two recent, legitimate fixes to `background.js` added real global usage the sandbox never got:
  • Every call on the success path threw `" is not defined"`, caught by the function's own `try/catch` and silently misreported as a typed `{ ok: false }` failure result instead of a real one -- which is exactly why this wasn't caught by any assertion on the error message itself, only by the tests expecting the actual success/failure shape.
  • Fix: inject both real globals into the sandboxed `context` object, mirroring how `chrome`/`fetch` are already provided.

Test plan

  • Reproduced deterministically outside CI (not a flake -- same failure every run, for any candidates payload reaching the success path)
  • `npx vitest run miner-extension-live-fetch` -- 15/15 passing after the fix (was 4-7 failing depending on run)
  • `npm run test:changed` against `origin/main` -- only this one file affected
  • `npm run typecheck` -- clean

…ve-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).
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 17, 2026
@JSONbored
JSONbored merged commit c23060e into main Jul 17, 2026
5 checks passed
@JSONbored
JSONbored deleted the fix/miner-extension-abortsignal-test-harness branch July 17, 2026 20:50
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.98%. Comparing base (c8d28b5) to head (05e7af4).
⚠️ Report is 34 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7092      +/-   ##
==========================================
+ Coverage   93.74%   95.98%   +2.23%     
==========================================
  Files         692      609      -83     
  Lines       68706    48144   -20562     
  Branches    18760    15133    -3627     
==========================================
- Hits        64409    46209   -18200     
+ Misses       3302     1118    -2184     
+ Partials      995      817     -178     
Flag Coverage Δ
rees ?
shard-1 43.34% <ø> (-0.46%) ⬇️
shard-2 36.89% <ø> (+0.04%) ⬆️
shard-3 33.16% <ø> (-0.11%) ⬇️
shard-4 34.39% <ø> (+0.48%) ⬆️
shard-5 31.67% <ø> (-0.57%) ⬇️
shard-6 46.07% <ø> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 83 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant