Skip to content

fix(deploy): opt out of bulletin-deploy memory-report on Bun#37

Merged
UtkarshBhardwaj007 merged 1 commit intomainfrom
fix/bulletin-deploy-bun-v8-crash
Apr 21, 2026
Merged

fix(deploy): opt out of bulletin-deploy memory-report on Bun#37
UtkarshBhardwaj007 merged 1 commit intomainfrom
fix/bulletin-deploy-bun-v8-crash

Conversation

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member

Summary

  • dot deploy was crashing on our Bun-compiled binary with node:v8 getHeapSpaceStatistics is not yet implemented in Bun. whenever it was invoked from a cwd whose git remote matched an internal Parity org.
  • Root cause: the old process.env.BULLETIN_DEPLOY_TELEMETRY = "0" assignment in src/index.ts ran after ES-module import hoisting. By then, bulletin-deploy/dist/telemetry.js had already computed its module-load-time DISABLED gate with the env var still undefined, isInternalContext() returned true, Sentry loaded, and on deploy-end withDeploySpan's finally called maybeWriteMemoryReportbuildMemoryReportv8.getHeapSpaceStatistics() — unimplemented in Bun.
  • Fix: new src/bootstrap.ts side-effect module, imported as the very first import of src/index.ts. ES-module evaluation is dependency-first + sibling-ordered (ECMA-262 §16.2 InnerModuleEvaluation walks [[RequestedModules]] in source order), which both Node ESM and bun build --compile preserve today, so bootstrap's side effects land before any bulletin-deploy transitive import.
  • Also forces BULLETIN_DEPLOY_MEM_REPORT=0 by default as defence-in-depth — that gate is checked at call time inside maybeWriteMemoryReport, so the v8 call is blocked even when a user explicitly re-enables telemetry.
  • Both vars still honour an explicit user override (BULLETIN_DEPLOY_TELEMETRY=1 dot deploy / BULLETIN_DEPLOY_MEM_REPORT=1 dot deploy) for Parity debugging.

Files

  • src/bootstrap.ts (new) — the env opt-out, export {} to force ESM module semantics so await import("./bootstrap.js") in tests resolves to a real module namespace.
  • src/bootstrap.test.ts (new) — five tests: opt-outs applied, overrides preserved, and a structural invariant asserting ./bootstrap.js is the first import in src/index.ts (catches future import-reorder regressions).
  • src/index.ts — adds import "./bootstrap.js"; as the first import, removes the now-redundant in-body env block.
  • CLAUDE.md — updates the process-guard invariant with the import-ordering rationale + ECMA-262 caveat.
  • .changeset/opt-out-bulletin-deploy-mem-report.md — patch changeset.

Test plan

  • pnpm test — 208/208 green (4 new bootstrap tests + 1 structural invariant test).
  • npx tsc --noEmit — clean.
  • pnpm cli:install then reproduce the original failing deploy command from a paritytech cwd. Expected: personhood error surfaces cleanly, no v8 stack.
  • Sanity: BULLETIN_DEPLOY_TELEMETRY=1 BULLETIN_DEPLOY_MEM_REPORT_THRESHOLD_MB=0 dot deploy should still succeed (defence-in-depth holds even with telemetry re-enabled).
  • Sanity: BULLETIN_DEPLOY_TELEMETRY=1 BULLETIN_DEPLOY_MEM_REPORT=1 BULLETIN_DEPLOY_MEM_REPORT_THRESHOLD_MB=0 dot deploy should reproduce the v8 crash again — proves the user override still wins.

`dot deploy` crashed on Bun-compiled binaries with
"node:v8 getHeapSpaceStatistics is not yet implemented in Bun" when run
from a cwd whose git remote matched an internal Parity org. The old
`BULLETIN_DEPLOY_TELEMETRY=0` assignment lived below the ES-module
imports in `src/index.ts`, so bulletin-deploy's `telemetry.ts` had
already computed its `DISABLED` gate before the opt-out ran. Sentry
loaded, `withDeploySpan`'s finally fired `maybeWriteMemoryReport`,
which calls `v8.getHeapSpaceStatistics()` — unimplemented in Bun.

Move the opt-out into `src/bootstrap.ts`, imported as the very first
import in `src/index.ts` so its side effects run before any sibling
import's top level. Also force `BULLETIN_DEPLOY_MEM_REPORT=0` by
default — that gate is checked at call time inside
`maybeWriteMemoryReport`, so it stops the v8 call even if a user
explicitly opts telemetry back in. Both vars still honour an explicit
user override.
@github-actions
Copy link
Copy Markdown
Contributor

Dev build ready — try this branch:

curl -fsSL https://raw.githubusercontent.com/paritytech/playground-cli/main/install.sh | VERSION=dev/fix/bulletin-deploy-bun-v8-crash bash

@UtkarshBhardwaj007 UtkarshBhardwaj007 merged commit 61e5042 into main Apr 21, 2026
5 checks passed
@UtkarshBhardwaj007 UtkarshBhardwaj007 deleted the fix/bulletin-deploy-bun-v8-crash branch April 21, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant