fix(deploy): opt out of bulletin-deploy memory-report on Bun#37
Merged
UtkarshBhardwaj007 merged 1 commit intomainfrom Apr 21, 2026
Merged
fix(deploy): opt out of bulletin-deploy memory-report on Bun#37UtkarshBhardwaj007 merged 1 commit intomainfrom
UtkarshBhardwaj007 merged 1 commit intomainfrom
Conversation
`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.
Contributor
|
Dev build ready — try this branch: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dot deploywas crashing on our Bun-compiled binary withnode:v8 getHeapSpaceStatistics is not yet implemented in Bun.whenever it was invoked from a cwd whose git remote matched an internal Parity org.process.env.BULLETIN_DEPLOY_TELEMETRY = "0"assignment insrc/index.tsran after ES-module import hoisting. By then,bulletin-deploy/dist/telemetry.jshad already computed its module-load-timeDISABLEDgate with the env var stillundefined,isInternalContext()returnedtrue, Sentry loaded, and on deploy-endwithDeploySpan'sfinallycalledmaybeWriteMemoryReport→buildMemoryReport→v8.getHeapSpaceStatistics()— unimplemented in Bun.src/bootstrap.tsside-effect module, imported as the very first import ofsrc/index.ts. ES-module evaluation is dependency-first + sibling-ordered (ECMA-262 §16.2InnerModuleEvaluationwalks[[RequestedModules]]in source order), which both Node ESM andbun build --compilepreserve today, so bootstrap's side effects land before any bulletin-deploy transitive import.BULLETIN_DEPLOY_MEM_REPORT=0by default as defence-in-depth — that gate is checked at call time insidemaybeWriteMemoryReport, so the v8 call is blocked even when a user explicitly re-enables telemetry.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 soawait 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.jsis the first import insrc/index.ts(catches future import-reorder regressions).src/index.ts— addsimport "./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:installthen reproduce the original failing deploy command from a paritytech cwd. Expected: personhood error surfaces cleanly, nov8stack.BULLETIN_DEPLOY_TELEMETRY=1 BULLETIN_DEPLOY_MEM_REPORT_THRESHOLD_MB=0 dot deployshould still succeed (defence-in-depth holds even with telemetry re-enabled).BULLETIN_DEPLOY_TELEMETRY=1 BULLETIN_DEPLOY_MEM_REPORT=1 BULLETIN_DEPLOY_MEM_REPORT_THRESHOLD_MB=0 dot deployshould reproduce the v8 crash again — proves the user override still wins.