Repository navigation
fix(update): retain late imports on Bun - #183429
Conversation
Keep runtime import retention on the supported Node and Bun hook APIs so the updater survives installation replacement and experimental AOT can link. Preserve CommonJS conditional exports and loaded state while sharing the existing package-format owner.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR adds Bun-compatible retained imports and corrects CommonJS resolution so an updater can finish after its installation is replaced. Example: A Bun updater imports dist/late-old-hash.mjs after activation replaces dist.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored PR open: it addresses a remaining runtime gap on current main, and inspection found no definite introduced defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe update runtime owner snapshots the running installation before replacement; runtime-specific module hooks then serve late imports from that snapshot while preserving original URLs and loaded state. flowchart TD
A[Update command] --> B[Retained runtime owner]
B --> C[Retained file inventory]
C --> D[Node module hooks]
C --> E[Bun plugin hooks]
D --> F[Original updater and cleanup]
E --> F
Technical reviewBest possible solution: Keep runtime-specific loading within the existing retention owner while sharing its inventory, module identities, and package-format classification. Do we have a high-confidence way to reproduce the issue? Current main unconditionally uses Node hooks, while the existing plugin loader explicitly routes Bun away from those hooks; the reported failure is source-supported, but no target code was executed during this read-only review. Is this the best way to solve the issue? The patch repairs the existing owner, preserves its cleanup lifetime, and shares the unchanged package-format helper; the runtime adapters and added fixture cases serve distinct loading contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 192947deb5f3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +153, Tests +57, Docs +4, Other +1. Total +215 across 7 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 4:44 AM ET / 08:44 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* fix(update): retain late imports on Bun Keep runtime import retention on the supported Node and Bun hook APIs so the updater survives installation replacement and experimental AOT can link. Preserve CommonJS conditional exports and loaded state while sharing the existing package-format owner. * fix(tooling): include shared module format in PR wrapper * docs(update): explain the Bun runtime type invariant
* fix(update): retain late imports on Bun Keep runtime import retention on the supported Node and Bun hook APIs so the updater survives installation replacement and experimental AOT can link. Preserve CommonJS conditional exports and loaded state while sharing the existing package-format owner. * fix(tooling): include shared module format in PR wrapper * docs(update): explain the Bun runtime type invariant (cherry picked from commit a355200) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes retained updater imports on Bun after an installation is replaced, and removes a Node-only named import that prevented experimental AOT binaries from linking.
User Impact
An updater running on Node or the pinned Bun runtime keeps using its original generation through cleanup, including CommonJS dependencies, JSON, and already-loaded module state. Imports outside that generation keep using the active installation. Standalone installations retain their existing immutable update path.
Why This Change Was Made
The retained-import owner now uses each runtime's supported hooks: Node's module hooks and Bun's public plugin resolver/loader. CommonJS and ESM keep their respective package export conditions. Both share the retained-file inventory and preserve original module identities while resolving against retained files. CommonJS uses native loading, and the existing package-format helper moves to the shared infra owner. Node's CommonJS resolution also explicitly uses the retained parent because changing a hook context's parent URL does not update its captured resolver.
Evidence
node:module.registerHooksimport could not link.Experimental compiler-runtime limitation: its ordinary Bun runtime currently skips public
onResolvecallbacks for bare package imports. A standalone 24-line reproducer fails on that compiler and passes on the pinned production Bun. Therefore the full mutable-update flow is qualified on Node and pinned Bun, while experimental AOT proof here covers linking and startup. Immutable standalone artifact behavior is validated separately.Inherited CI failure on final head: run 40176730508 failed UI shard 5/7 only in
cloud-workers-settings.e2e.test.ts, reconnect profile deletion, where the row remained after one patch request. The inspected CI merge has byte-identical UI/config/Gateway-client source, dependency manifests, and test launchers to its main parent. This PR does not execute its retained-import path in that mocked browser flow. The focused replay passes (1.958 seconds test time, 33.97 seconds including the UI build); that replay does not establish a repair. The timing cause remains unresolved and the failed result is retained for native inherited-failure admission. Security and required reviews remain enforced.