Repository navigation
worker_threads: use the intrinsic MessagePort and MessageChannel, not the mutable globals - #40271
Conversation
…ding the globals new Worker() read MessagePort, MessageChannel, BroadcastChannel, and Worker from the mutable globals when node:worker_threads loaded. Code that replaces them before the module loads (happy-dom's global registrator) made Worker construction throw "port.on is not a function" from registerMainThreadPort. The native binding now hands the module the intrinsic constructors, so a replaced global cannot reach worker_threads internals or its exports. Fixes #40268
|
Warning Review limit reached
On-demand reviews are free for the next 28 days. After that, they cost $0.25 per reviewed file. Or wait 23 seconds for your next included review. View limit detailsLimit details: You’ve used all 5 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
Comment |
There was a problem hiding this comment.
LGTM — targeted regression fix that swaps mutable-global reads for the intrinsic constructors from the native binding.
What was reviewed:
- Verified
JS{MessagePort,MessageChannel,BroadcastChannel,Worker}::getConstructorall exist and return the cached per-global constructor; new includes added for the two not already present. - Confirmed
initThreadInforuns at module load before anycreateMessagingChannelcall, so the module-localMessageChannelinmessaging.tsis always set before use. - Checked no other
globalThis.{MessagePort,MessageChannel,Worker,BroadcastChannel}reads remain in the touched builtins. - Test follows harness conventions (spawned subprocess, concurrent pipe drain, stderr/stdout asserted before exitCode).
Extended reasoning...
Overview
Fixes #40268: new Worker() from node:worker_threads threw port.on is not a function when user code (e.g. happy-dom) replaced globalThis.MessagePort before the module loaded. The fix moves the four web constructors (MessagePort, MessageChannel, BroadcastChannel, Worker) from globalThis reads to the native createNodeWorkerThreadsBinding array (indices 13-16), and threads the intrinsic MessageChannel into internal/worker/messaging.ts via the existing initThreadInfo call. Four files touched: two builtin TS modules, one C++ binding function, one new regression test.
Security risks
None. This removes a userland-tampering vector (replacing globals could previously hijack worker_threads internals). getConstructor returns the JSC-cached per-global constructor, not anything user-controllable.
Level of scrutiny
Low-to-moderate. The change is mechanical: extend an existing binding array by 4 entries using the standard generated getConstructor pattern, and destructure them on the TS side in place of globalThis reads. No control-flow changes, no new state, no lifecycle changes. The C++ additions follow the exact local convention (no RETURN_IF_EXCEPTION between putDirectIndex calls, matching the 13 preceding entries). I verified all four getConstructor methods exist on the generated wrapper classes and that the two new headers are properly included.
Other factors
- The fix covers the whole class (all four constructors), not just the one that triggered the reported symptom — matches the repo's "fix the bug class" guidance.
initThreadInfois called atworker_threads.tsmodule-load time, strictly before anyWorkerconstructor runs, socreateMessagingChannel's module-localMessageChannelis always initialized before use.- Regression test is hermetic (subprocess with
-e, no network/fs), drains stdout/stderr/exited concurrently, and asserts output before exit code per harness conventions. It exercises all four replaced globals plus the actualnew Workerpath that regressed. - PR description confirms the existing
test/js/node/worker_threads/suite (137 tests) still passes. - No CODEOWNERS coverage for these paths.
|
Updated 5:31 PM PT - Aug 23rd, 2026
✅ @robobun, your commit 53c89b535b55830fb6831914614dc975973a5878 passed in 🧪 To try this PR locally: bunx bun-pr 40271That installs a local version of the PR into your bun-40271 --bun |
The node-flavoured BroadcastChannel subclass now extends the intrinsic the native binding hands over (#40271) instead of the mutable global, and is declared after that binding.
* build(bun): pin Bun 1.4.2 Bun 1.4.2's `crypto.verify` hashes EC keys with SHA-256 when no digest is named, as Node and OpenSSL do; 1.4.0 throws NO_DEFAULT_DIGEST. sigstore-js and tuf-js verify that way, so the npm provenance verifier needs it. `ec-verify-without-digest.test.ts` pins the property and fails on 1.4.0. Workers Builds selects Bun only through its `BUN_VERSION` build variable, one list per trigger (production and preview), and `scripts/workers-build.ts` refuses a mismatch with `.bun-version`. The deployment doc gives the cutover order, and a test keeps its `BUN_VERSION` equal to the pin. Bun 1.4.2's plain `bun install` corrects sdk-noir's stale workspace version in `bun.lock`; `--frozen-lockfile` accepts the committed lock unchanged on both versions. The lock is left as is because that entry is in presto-noir's release slice; follow-ups.md tracks folding it into the next noir release. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(follow-ups): carry the JEST_WORKER_ID preloads with the Bun pin Their removal condition is a Bun carrying oven-sh/bun#40271, which 1.4.2 is. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…111) * docs(plan): open presto-verifier-identity The verifier binds a provenance statement to its signing identity before any claim in it is trusted. The plan is at the approval gate because it adds a verification policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): approve presto-verifier-identity with decision A The publish job stays dependency-free beside its OIDC identity; identity binding lives in every consumer and in the reusable workflow's verify job. The consumer list and the dependency table now match the implementation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(deps): add the sigstore verification packages Exact root devDependencies, each past the 7-day release-age gate: @sigstore/verify 4.1.2, @sigstore/tuf 5.0.0 and @sigstore/bundle 5.0.0 for verification, and @sigstore/mock 0.13.0 with @sigstore/protobuf-specs 0.5.2 (the version the others already resolve) for tests. The lock adds only their subtree: 43 packages added, none removed or changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(release): bind provenance statements to their signing identity The verifier binds a provenance statement to its signing identity. Before any claim is used, the Sigstore bundle npm verified is verified again with @sigstore/verify against an explicit policy: the GitHub Actions issuer, the signing workflow (the SAN, anchored and escaped, and its build signer extension), release-sdk.yml as the build config, the repository URI and its immutable repository and owner IDs, refs/heads/main, a GitHub-hosted runner, and the source commit in both the repository digest and build config digest extensions. The statement's repository, workflow, ref and commit must then equal the certificate's, and an expected commit must equal both. Only rollback accepts the reusable workflow's earlier name as signer. Trust is Sigstore's public-good root through TUF. The OIDC publish job runs no dependency code: its registry checks move to the dependency-free registry-consistency.ts, and the reusable workflow's verify job, after a frozen install with --ignore-scripts, runs the identity-bound verifier, whose failure fails the workflow. Release planning, promotion and the production playground build take the bound verifier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): prove the signing identity binding A mock Sigstore world (CA with CT log, transparency log, trusted root) signs the release's own statement, and the release identity verifies through both entry points; each certificate field changed alone is refused for that field. The real presto 6.0.0-rc.3 bundle verifies at its release commit and no other; presto 5.2.0 verifies only on the rollback path. A live test against the registry and TUF runs with PRESTO_LIVE_PROVENANCE set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(ci): say what the packaged-e2e SDK swap does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(release): verify with freshly installed, locked bytes only The reusable workflow's verify job installs from the registry against bun.lock with no restored package cache, so the identity-bound verifier never runs files a job that ran dependency code could have saved. The registry-consistency helper reads the installed version from the package's manifest instead of spawning node. The isolation contract now also requires that Bun runs only repository script files in the credentialed job, and refuses `require`, computed imports and spawned interpreters or package runners anywhere in their import graph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): prove tampered bundles fail cryptographically A changed payload, another signer's certificate, a second envelope signature, a log entry with another integrated time and another signature's log entry are each refused by the cryptographic checks, never as an identity mismatch, with the release and the rollback signers alike. presto 5.2.0 runs through the report path too, and a complete presto-core 1.2.1 bundle verifies offline at its release commit; the trimmed presto-core 1.0.0 report is labelled as claim extraction only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): record presto-verifier-identity's final boundary and gates The plan states the exact certificate fields pinned and why the others are not, the verify job's cache-free install and the final contract assertions; the lessons log the gates and consults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): guard every code path beside the publish credentials The credentialed job's commands may run Bun only on repository scripts, inline Node only without loading code, and npm only to publish or read. Every module those scripts reach is refused `require`, non-literal imports and any subprocess other than npm reading the registry or installing without scripts, whether spawned from a literal array or through a helper whose calls all pass one. Each refused form is a test row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): state the credentialed-job guard and keep lessons technical Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): allow only exact npm reads beside the publish credentials npm runs only `view` with positional values, `audit signatures`, or `install` with an exact flag set that includes `--ignore-scripts`, so no override, spread or other audit mode passes. Spawn calls are matched regardless of spacing, a spawn whose command is not a literal array or the reviewed helper is refused, and Node in the job runs only quoted inline code that loads nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): close presto-verifier-identity Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(release): give EC signature checks a digest on Bun 1.4.0 Bun 1.4.0, the pinned runtime, has no default digest for EC keys: `crypto.verify(null, ...)` throws ERR_OSSL_EVP_NO_DEFAULT_DIGEST where Node, OpenSSL and Bun 1.4.2 use SHA-256. sigstore-js checks inclusion promises and tuf-js checks root metadata that way and read the throw as a bad signature, so every verification failed closed. On such a runtime only, ec-default-digest.ts makes a null digest with an EC key, bare or wrapped as `{ key }`, SHA-256; the identity module loads it first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(release): state when the EC digest shim retires The shim's comment names what it wraps and its removal condition, `.bun-version` at 1.4.2 or newer; follow-ups.md carries that Bun bump, the tag-after-verification decision and the reuse-pin hardening. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(bun): pin Bun 1.4.2 Bun 1.4.2 verifies EC signatures with SHA-256 when no digest is named, as Node and OpenSSL do; sigstore-js and tuf-js verify that way. Every setup-bun step reads `.bun-version`. Workers Builds refuses a Bun other than `.bun-version`, so its `BUN_VERSION` build variable moves with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(release): verify EC signatures on the pinned runtime, without a crypto shim On Bun 1.4.2 `crypto.verify` with no digest hashes EC keys with SHA-256, so the wrapper that supplied it on Bun 1.4.0 goes, with its import and its path-filter entry. The runtime property stays under test in its own file, for a bare key and `{ key }`, a null and an undefined digest: tuf-js reaches it only in the live provenance test, so a Bun bump that loses it fails here first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): record Bun 1.4.2 as the verifier's runtime The presto-verifier-identity record ships Bun 1.4.2 instead of a crypto wrapper, with the live gate re-run under it (80 checks), and drops the bump from the open items. follow-ups.md trades it for the `JEST_WORKER_ID` preloads, whose stated removal condition Bun 1.4.2 meets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(bun): pin Bun 1.4.2 Bun 1.4.2's `crypto.verify` hashes EC keys with SHA-256 when no digest is named, as Node and OpenSSL do; 1.4.0 throws NO_DEFAULT_DIGEST. sigstore-js and tuf-js verify that way, so the npm provenance verifier needs it. `ec-verify-without-digest.test.ts` pins the property and fails on 1.4.0. Workers Builds selects Bun only through its `BUN_VERSION` build variable, one list per trigger (production and preview), and `scripts/workers-build.ts` refuses a mismatch with `.bun-version`. The deployment doc gives the cutover order, and a test keeps its `BUN_VERSION` equal to the pin. Bun 1.4.2's plain `bun install` corrects sdk-noir's stale workspace version in `bun.lock`; `--frozen-lockfile` accepts the committed lock unchanged on both versions. The lock is left as is because that entry is in presto-noir's release slice; follow-ups.md tracks folding it into the next noir release. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(follow-ups): carry the JEST_WORKER_ID preloads with the Bun pin Their removal condition is a Bun carrying oven-sh/bun#40271, which 1.4.2 is. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): name why a published release does not verify Release planning read any failed check of a published version as "does not verify; bump the version", including a Sigstore TUF mirror, npm registry or GitHub API it could not reach. A transient outage therefore advised a needless version bump. The refusal still fails closed, and now carries the reason: a missing tag or GitHub release, a commit mismatch, or the error of the check that could not run, and says to rerun when the check could not reach a service. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(deps): leave presto-noir's lockfile entry as its release has it Installing the sigstore packages also rewrote `packages/sdk-noir`'s workspace version in `bun.lock` from 2.0.0-rc.1 to 2.0.0-rc.2, which a plain Bun 1.4.2 install does. That entry is in noir's release slice, and the `@alejoamiras/presto-noir@2.0.0-rc.2` tag commit has rc.1, so release planning refused to reuse the published 2.0.0-rc.2 ("build inputs changed since its release tag"). With the line restored, `bun install --frozen-lockfile` leaves the lock unchanged and a dry-run plan of all packages reuses core, noir and banners again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): give up on an npm call that never answers A registry, or a proxy, that accepts the connection and never answers held `npm install` with no deadline: a provenance check through one was still waiting after 25 minutes, so the release job would sit until its own timeout. Each npm call now fails after 180 s, naming the command; a cold install and audit of the largest package take about 30 s. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): name the cause behind a wrapped verification error `@sigstore/tuf` wraps every metadata refresh failure as `error refreshing TUF metadata`, keeping the code and the underlying error as separate properties, so a refused reuse showed the wrapper and hid whether TUF was unreachable or its metadata invalid. The refusal now carries each error's code and its cause chain. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…erifies (#121) * docs(plan): open presto-verifier-identity The verifier binds a provenance statement to its signing identity before any claim in it is trusted. The plan is at the approval gate because it adds a verification policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): approve presto-verifier-identity with decision A The publish job stays dependency-free beside its OIDC identity; identity binding lives in every consumer and in the reusable workflow's verify job. The consumer list and the dependency table now match the implementation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(deps): add the sigstore verification packages Exact root devDependencies, each past the 7-day release-age gate: @sigstore/verify 4.1.2, @sigstore/tuf 5.0.0 and @sigstore/bundle 5.0.0 for verification, and @sigstore/mock 0.13.0 with @sigstore/protobuf-specs 0.5.2 (the version the others already resolve) for tests. The lock adds only their subtree: 43 packages added, none removed or changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(release): bind provenance statements to their signing identity The verifier binds a provenance statement to its signing identity. Before any claim is used, the Sigstore bundle npm verified is verified again with @sigstore/verify against an explicit policy: the GitHub Actions issuer, the signing workflow (the SAN, anchored and escaped, and its build signer extension), release-sdk.yml as the build config, the repository URI and its immutable repository and owner IDs, refs/heads/main, a GitHub-hosted runner, and the source commit in both the repository digest and build config digest extensions. The statement's repository, workflow, ref and commit must then equal the certificate's, and an expected commit must equal both. Only rollback accepts the reusable workflow's earlier name as signer. Trust is Sigstore's public-good root through TUF. The OIDC publish job runs no dependency code: its registry checks move to the dependency-free registry-consistency.ts, and the reusable workflow's verify job, after a frozen install with --ignore-scripts, runs the identity-bound verifier, whose failure fails the workflow. Release planning, promotion and the production playground build take the bound verifier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): prove the signing identity binding A mock Sigstore world (CA with CT log, transparency log, trusted root) signs the release's own statement, and the release identity verifies through both entry points; each certificate field changed alone is refused for that field. The real presto 6.0.0-rc.3 bundle verifies at its release commit and no other; presto 5.2.0 verifies only on the rollback path. A live test against the registry and TUF runs with PRESTO_LIVE_PROVENANCE set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(ci): say what the packaged-e2e SDK swap does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(release): verify with freshly installed, locked bytes only The reusable workflow's verify job installs from the registry against bun.lock with no restored package cache, so the identity-bound verifier never runs files a job that ran dependency code could have saved. The registry-consistency helper reads the installed version from the package's manifest instead of spawning node. The isolation contract now also requires that Bun runs only repository script files in the credentialed job, and refuses `require`, computed imports and spawned interpreters or package runners anywhere in their import graph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): prove tampered bundles fail cryptographically A changed payload, another signer's certificate, a second envelope signature, a log entry with another integrated time and another signature's log entry are each refused by the cryptographic checks, never as an identity mismatch, with the release and the rollback signers alike. presto 5.2.0 runs through the report path too, and a complete presto-core 1.2.1 bundle verifies offline at its release commit; the trimmed presto-core 1.0.0 report is labelled as claim extraction only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): record presto-verifier-identity's final boundary and gates The plan states the exact certificate fields pinned and why the others are not, the verify job's cache-free install and the final contract assertions; the lessons log the gates and consults. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): guard every code path beside the publish credentials The credentialed job's commands may run Bun only on repository scripts, inline Node only without loading code, and npm only to publish or read. Every module those scripts reach is refused `require`, non-literal imports and any subprocess other than npm reading the registry or installing without scripts, whether spawned from a literal array or through a helper whose calls all pass one. Each refused form is a test row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): state the credentialed-job guard and keep lessons technical Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(release): allow only exact npm reads beside the publish credentials npm runs only `view` with positional values, `audit signatures`, or `install` with an exact flag set that includes `--ignore-scripts`, so no override, spread or other audit mode passes. Spawn calls are matched regardless of spacing, a spawn whose command is not a literal array or the reviewed helper is refused, and Node in the job runs only quoted inline code that loads nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): close presto-verifier-identity Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(release): give EC signature checks a digest on Bun 1.4.0 Bun 1.4.0, the pinned runtime, has no default digest for EC keys: `crypto.verify(null, ...)` throws ERR_OSSL_EVP_NO_DEFAULT_DIGEST where Node, OpenSSL and Bun 1.4.2 use SHA-256. sigstore-js checks inclusion promises and tuf-js checks root metadata that way and read the throw as a bad signature, so every verification failed closed. On such a runtime only, ec-default-digest.ts makes a null digest with an EC key, bare or wrapped as `{ key }`, SHA-256; the identity module loads it first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(release): state when the EC digest shim retires The shim's comment names what it wraps and its removal condition, `.bun-version` at 1.4.2 or newer; follow-ups.md carries that Bun bump, the tag-after-verification decision and the reuse-pin hardening. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(bun): pin Bun 1.4.2 Bun 1.4.2 verifies EC signatures with SHA-256 when no digest is named, as Node and OpenSSL do; sigstore-js and tuf-js verify that way. Every setup-bun step reads `.bun-version`. Workers Builds refuses a Bun other than `.bun-version`, so its `BUN_VERSION` build variable moves with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(release): verify EC signatures on the pinned runtime, without a crypto shim On Bun 1.4.2 `crypto.verify` with no digest hashes EC keys with SHA-256, so the wrapper that supplied it on Bun 1.4.0 goes, with its import and its path-filter entry. The runtime property stays under test in its own file, for a bare key and `{ key }`, a null and an undefined digest: tuf-js reaches it only in the live provenance test, so a Bun bump that loses it fails here first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(plan): record Bun 1.4.2 as the verifier's runtime The presto-verifier-identity record ships Bun 1.4.2 instead of a crypto wrapper, with the live gate re-run under it (80 checks), and drops the bump from the open items. follow-ups.md trades it for the `JEST_WORKER_ID` preloads, whose stated removal condition Bun 1.4.2 meets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(bun): pin Bun 1.4.2 Bun 1.4.2's `crypto.verify` hashes EC keys with SHA-256 when no digest is named, as Node and OpenSSL do; 1.4.0 throws NO_DEFAULT_DIGEST. sigstore-js and tuf-js verify that way, so the npm provenance verifier needs it. `ec-verify-without-digest.test.ts` pins the property and fails on 1.4.0. Workers Builds selects Bun only through its `BUN_VERSION` build variable, one list per trigger (production and preview), and `scripts/workers-build.ts` refuses a mismatch with `.bun-version`. The deployment doc gives the cutover order, and a test keeps its `BUN_VERSION` equal to the pin. Bun 1.4.2's plain `bun install` corrects sdk-noir's stale workspace version in `bun.lock`; `--frozen-lockfile` accepts the committed lock unchanged on both versions. The lock is left as is because that entry is in presto-noir's release slice; follow-ups.md tracks folding it into the next noir release. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(follow-ups): carry the JEST_WORKER_ID preloads with the Bun pin Their removal condition is a Bun carrying oven-sh/bun#40271, which 1.4.2 is. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): name why a published release does not verify Release planning read any failed check of a published version as "does not verify; bump the version", including a Sigstore TUF mirror, npm registry or GitHub API it could not reach. A transient outage therefore advised a needless version bump. The refusal still fails closed, and now carries the reason: a missing tag or GitHub release, a commit mismatch, or the error of the check that could not run, and says to rerun when the check could not reach a service. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(deps): leave presto-noir's lockfile entry as its release has it Installing the sigstore packages also rewrote `packages/sdk-noir`'s workspace version in `bun.lock` from 2.0.0-rc.1 to 2.0.0-rc.2, which a plain Bun 1.4.2 install does. That entry is in noir's release slice, and the `@alejoamiras/presto-noir@2.0.0-rc.2` tag commit has rc.1, so release planning refused to reuse the published 2.0.0-rc.2 ("build inputs changed since its release tag"). With the line restored, `bun install --frozen-lockfile` leaves the lock unchanged and a dry-run plan of all packages reuses core, noir and banners again. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(release): record a publication only after its signing identity verifies The publish job holding npm's OIDC identity drops `contents: write`, and its checkout keeps no credential. A new `release-records` job, `contents: write` with no OIDC identity and no install, creates the git tag and GitHub release after `verify` has bound the provenance to the release signing identity, then reads both back. No job holds both credentials. A publication whose verification fails stays on npm under `testnet` without records. Release planning refuses to reuse it and names the missing record, promotion refuses it before touching npm, and dependants and the playground pin wait on the whole reusable workflow. "Re-run failed jobs" completes a run whose verification failed transiently: `publish` does not run again, a tag already at the run's commit is a no-op push, and an existing release is kept. The runbook gives the owner the commands that check both records, and the path for an identity that does not verify. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): give up on an npm call that never answers A registry, or a proxy, that accepts the connection and never answers held `npm install` with no deadline: a provenance check through one was still waiting after 25 minutes, so the release job would sit until its own timeout. Each npm call now fails after 180 s, naming the command; a cold install and audit of the largest package take about 30 s. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): name the cause behind a wrapped verification error `@sigstore/tuf` wraps every metadata refresh failure as `error refreshing TUF metadata`, keeping the code and the underlying error as separate properties, so a refused reuse showed the wrapper and hid whether TUF was unreachable or its metadata invalid. The refusal now carries each error's code and its cause chain. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): finish a draft release that an interrupted record left `gh release create` uploads assets to a draft and publishes it last, so a `Record <package>` attempt interrupted mid-upload leaves a draft that `gh release view` still finds. A rerun took that for a finished release, and the read-back checked only its tag. A rerun now uploads the asset and publishes the draft, and the read-back requires a published release with its asset. Both steps are tested by running them with git and gh stubbed. The runbook now starts from the job that failed. A failed `Publish` must not be re-run, since npm refuses the existing version; the hand repair keeps a tag already at the verified commit and creates only the missing release. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): accept only a published release as a record `gh release view` also finds drafts. Release planning and promotion took a draft that an interrupted `Record` left for a finished record, so a version whose release was never published could be reused or promoted. Both now require a published release; a draft still counts as an existing record when planning checks that a new version is free. `Record` now finishes only a draft it could have left: authored by github-actions[bot], titled with the tag, holding no asset but its own. It stops on any other draft, and the read-back requires exactly the expected asset. The runbook re-runs one job at a time, since "Re-run failed jobs" would also re-run a failed `Publish`. The hand repair attaches the migration guide as it was at the verified commit, not from the operator's checkout. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(release): keep a tag already at the run's commit, annotated or not A hand repair creates a signed annotated tag, and pushing a lightweight tag of the same name cannot update it, so a rerun of Record failed before it reached the release. Resolve the remote tag first: absent, create and push; at this commit, keep it; anywhere else, stop. The step tests drive all four cases, and the read-back accepts an annotated tag. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
new Worker()fromnode:worker_threadsthrowsTypeError: port.on is not a function(inregisterMainThreadPort,internal:worker/messaging) on 1.4.0 when user code replacedglobalThis.MessagePortbefore the module loads. happy-dom's global registrator does this, so every suite that preloads it and constructs a worker (pino transports through thread-stream) broke. Worked on 1.3.14.src/js/node/worker_threads.tscapturedglobalThis.MessagePort(line 284) andglobalThis.MessageChannelat module load, andsrc/js/internal/worker/messaging.ts:162callednew globalThis.MessageChannel(). With a replaced global, the node-style emitter methods land on the replacement's prototype and the nativeMessagePort.prototypenever gets.on. The 1.4.0postMessageToThreadhub madenew Workercall.onon a native port, which exposed the latent bug.Fix
createNodeWorkerThreadsBinding(src/jsc/bindings/webcore/Worker.cpp) now appends the intrinsicMessagePort,MessageChannel,BroadcastChannel, andWorkerconstructors (viaJS*::getConstructor, which returns the cached per-global constructor) to the binding array.worker_threads.tstakes all four from the binding instead ofglobalThis, and passes the intrinsicMessageChannelintomessaging.tsthroughinitThreadInfo.test/regression/issue/40268.test.ts(fails on stock bun, passes with the fix). Alsotest/js/node/worker_threads/(137 pass), the worker transfer/dispose/TLA suites, and the node parallel message-port tests.Background
node:worker_threadswraps the webWorker/MessagePort. At module load it grafts Node'sEventEmitter-style methods (on,off,once, ...) ontoMessagePort.prototype(injectFakeEmitter).postMessageToThread(Node 22+) makes the main thread a message hub:new Workercreates a controlMessageChanneland registers the hub-side port withport.on("message", ...). That registration is the call that threw.getConstructorreturns the same constructor object the global property was initialized with, soinstanceofand prototype identity are unchanged for untouched globals.Notes
globalThis.MessagePortwith a class extendingEventTarget, thennew Worker("", { eval: true }). Printsokon 1.3.14 and with this fix, throws on 1.4.0.test/js/web/workers/worker.test.tshas two failures on a debug build ("message flood" and "preload with an un-awaited import()"). Both fail identically on main without this diff (verified with the diff stashed) and pass on the release build, so they are pre-existing debug-build timing failures.BroadcastChannelandWorker: the same mutable-global read, soworker_threads.BroadcastChannelno longer becomes the replacement class, and a replacedglobalThis.Workercannot hijacknew Workerinternals.[review] gate passed · iteration 0 · 4 files touched
fails on main (without fix)
passes on PR (with fix)
diff hotspot
gate history · 1 passed · 0 rejected · iteration 0
evidence per changed file
root cause · written by the author bot
The node:worker_threads module read MessagePort and MessageChannel from the mutable global object, so when user code such as happy-dom's registrator replaced globalThis.MessagePort before the module loaded, Bun's internal messaging code received a DOM-shaped port without emitter methods and threw "port.on is not a function" during Worker construction. The fix has the native worker_threads binding supply the intrinsic MessagePort, MessageChannel, BroadcastChannel, and Worker constructors directly, and the module's internals now use those instead of the globals. As a result, Worker constructi…