Skip to content

fix(runtime): preserve bundled loading and cancellation errors - #32

Merged
steipete merged 2 commits into
mainfrom
codex/bun-bundle-safe-undici
Sep 6, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/bun-bundle-safe-undici

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Two compatibility gaps were found while upgrading OpenClaw from Proxyline 0.3.7:

  • The installed-peer lookup added in 0.3.10 remains a runtime require.resolve('undici/package.json') after bundling. Relocated standalone output fails with MODULE_NOT_FOUND; OpenClaw's existing worker regression caught it in #140411.
  • The pending HTTP-forward and CONNECT cancellation hooks added in the intervening releases replace an explicit request.destroy(error) reason with a new CONNECT_FAILED error, losing caller identity and classification.

Change

Use a static undici/index.js import. It selects the installed peer under Bun and lets Node-targeted bundlers include it, removing the dynamic metadata lookup. Forward a supplied destruction error through the existing single-settlement path; no-error closure keeps its existing fallback, and timeout handling stays separate.

Add owner-boundary regressions for relocated bundled execution and both cancellation paths. The bundle test checks in-memory fetch, restoration of all captured globals, empty stderr, natural child exit, and owned temporary cleanup. Cancellation tests assert exact error identity, one error, closed requests, zero proxy application traffic, and awaited fixture cleanup. Declare already-locked esbuild 0.28.2 as a direct test dependency. Prepare patch release 0.3.11 and retain 0.3.12 Unreleased.

Evidence

Exact final head: 27fbaa914f2e795223321785428479778cd50727.

Fresh Node regressions failed before their repairs: relocated output could not find undici/package.json, and both pending cancellations replaced SYNTHETIC_CANCEL with CONNECT_FAILED. All three new regressions pass on Node 26.8.1 and Bun 1.4.2. The bundle child uses the same runtime as its outer test.

pattern='^(built runtime restores fetch globals in a relocated standalone bundle|pending (forward|connect) requests preserve caller destruction errors)$'
node --import tsx --test --test-name-pattern="$pattern" test/e2e.test.ts test/package-artifact.test.ts
bun test --test-name-pattern="$pattern" test/e2e.test.ts test/package-artifact.test.ts

Actual final-head Bun output (exit 0):

bun test v1.4.2 (744846f84)

test/package-artifact.test.ts:
(pass) built runtime restores fetch globals in a relocated standalone bundle [105.45ms]

test/e2e.test.ts:
(pass) pending forward requests preserve caller destruction errors [94.47ms]
(pass) pending connect requests preserve caller destruction errors [22.00ms]

 3 pass
 87 filtered out
 0 fail
Ran 3 tests across 2 files. [269.00ms]

The corresponding Node run reports the same three cases passed with exit 0. Additional evidence:

  • Five ordinary package-entrypoint cases pass on Node and Bun: globals/restoration, multipart encoding, and real loopback proxy redirect/body/streaming behavior.
  • An isolated packed 0.3.11 consumer with minimum peer Undici 8.5.0 passes shared-peer identity, in-memory fetch, and restoration on both runtimes.
  • Typecheck/build, both artifact tests, docs build, and fresh complete-candidate P2 review pass.
  • Independent source review covered all production changes since v0.3.7 in env.ts, node-http.ts, and runtime.ts. It identified the cancellation issue above; reinspection after correction found no remaining finding. Request ownership follows Node's pool selection, cleanup remains owner-bound, observer failures cannot strand globals, hostname normalization preserves matching, and explicit zero timeouts remain unbounded.

The existing full Node CI matrix and package verification gate release. Other policy/TLS/adversarial cases were not run locally, and this does not claim complete Bun compatibility across every networking surface.

@steipete
steipete requested a review from a team as a code owner September 6, 2026 20:29
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:46 PM ET / 20:46 UTC.

ClawSweeper review

What this changes

The PR makes the installed Undici peer bundleable, preserves caller cancellation errors during pending proxy connections, adds regressions, and prepares version 0.3.11.

Merge readiness

✅ Ready for maintainer review

Both repairs remain necessary on current main and v0.3.10. The final-head evidence supports the changed behavior, and review found no blocking defect or additional required action.

Priority: P2
Reviewed head: 27fbaa914f2e795223321785428479778cd50727

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused production changes have convincing before/after runtime evidence, minimum-peer coverage, and no identified correctness or security blocker.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Captured final-head Node and Bun runs exercise the relocated built runtime and explicit cancellation through real production HTTP agents, observing successful fetch/restoration and exact cancellation error identity with request closure; isolated minimum-peer consumer evidence also covers ordinary loading.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Captured final-head Node and Bun runs exercise the relocated built runtime and explicit cancellation through real production HTTP agents, observing successful fetch/restoration and exact cancellation error identity with request closure; isolated minimum-peer consumer evidence also covers ordinary loading.
Evidence reviewed 7 items Pinned change and current-main necessity: The complete introduced diff replaces main's dynamic Undici package-metadata lookup and passes supplied destruction errors through both existing settlement paths. The host pins the merge base to c6e7965 and the reviewed head to 27fbaa9; neither repair is present in that main revision.
Cancellation ownership and cleanup: Both agents retain their settlement guards, socket destruction, timeout cleanup, and request-hook restoration. The introduced change forwards the supplied Error without changing no-error closure or timeout fallbacks.
Final-head production-path evidence: The supplied complete PR body, captured under sourceRevision 45e2ef41da8ecc570049b01b0d512034d52491b06a2d52e286b412d47dbc47eb, records three passing final-head cases on Bun 1.4.2 and corresponding Node 26.8.1 success after reported before-fix failures. Source inspection confirms real http/https requests through production agents, explicit destroy(error), exact error identity, one error, request closure, and zero proxy application events. The relocated bundle executes the built runtime in a child process and checks fetch, global restoration, empty stderr, and natural exit. These are executable production boundaries, not mocked transport clients. No reviewer-side execution was performed.
Findings None None.
Security None None.

How this fits together

Proxyline applies process-wide proxy routing to Node HTTP clients and Undici fetch. Its runtime installs and restores networking globals, while its request agents manage forward-proxy connections and CONNECT tunnels.

flowchart TD
  A[Application requests] --> B[Proxyline runtime]
  C[Installed Undici peer] --> B
  B --> D[Fetch dispatcher]
  B --> E[Node proxy agents]
  E --> F[Forward connection or CONNECT tunnel]
  G[Caller cancellation error] --> E
  E --> H[Request settles with original error]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta Production +24/-35 (net -11); tests +105/-0 The repair reduces production code while adding focused coverage for bundle relocation and both cancellation paths.

Technical review

Best possible solution:

Retain one installed Undici implementation across ordinary and bundled consumers, and preserve caller error identity through the existing request-cleanup path.

Do we have a high-confidence way to reproduce the issue?

Yes: main's dynamic metadata lookup and discarded destroy(error) argument establish concrete failure paths, supported by the contributor's failing-before/passing-after runs; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes: a static import of the same installed peer and propagation through existing settlement guards address the defects without adding settings, parallel APIs, or migration requirements.

AGENTS.md: not found in the target repository.

Codex review notes: model internal, reasoning medium; reviewed against c6e79655ca1d.

Labels

Label justifications:

  • P2: This is a bounded compatibility repair for standalone bundles and pending-request error propagation.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Captured final-head Node and Bun runs exercise the relocated built runtime and explicit cancellation through real production HTTP agents, observing successful fetch/restoration and exact cancellation error identity with request closure; isolated minimum-peer consumer evidence also covers ordinary loading.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured final-head Node and Bun runs exercise the relocated built runtime and explicit cancellation through real production HTTP agents, observing successful fetch/restoration and exact cancellation error identity with request closure; isolated minimum-peer consumer evidence also covers ordinary loading.

Evidence

What I checked:

  • Pinned change and current-main necessity: The complete introduced diff replaces main's dynamic Undici package-metadata lookup and passes supplied destruction errors through both existing settlement paths. The host pins the merge base to c6e7965 and the reviewed head to 27fbaa9; neither repair is present in that main revision. (src/runtime.ts:21, 27fbaa914f2e)
  • Cancellation ownership and cleanup: Both agents retain their settlement guards, socket destruction, timeout cleanup, and request-hook restoration. The introduced change forwards the supplied Error without changing no-error closure or timeout fallbacks. (src/node-http.ts:576, 27fbaa914f2e)
  • Final-head production-path evidence: The supplied complete PR body, captured under sourceRevision 45e2ef41da8ecc570049b01b0d512034d52491b06a2d52e286b412d47dbc47eb, records three passing final-head cases on Bun 1.4.2 and corresponding Node 26.8.1 success after reported before-fix failures. Source inspection confirms real http/https requests through production agents, explicit destroy(error), exact error identity, one error, request closure, and zero proxy application events. The relocated bundle executes the built runtime in a child process and checks fetch, global restoration, empty stderr, and natural exit. These are executable production boundaries, not mocked transport clients. No reviewer-side execution was performed. (test/e2e.test.ts:255, 27fbaa914f2e)
  • Installed-peer and bundle compatibility: The direct undici/index.js import establishes the relevant dependency contract. The captured body additionally reports an isolated packed consumer using minimum supported Undici 8.5.0 on Node and Bun, checking shared-peer identity, fetch, and restoration. The artifact regression bundles the real dist entrypoint and relocates its output before execution. (test/package-artifact.test.ts:75, 27fbaa914f2e)
  • Release and supply-chain scope: The supplied latest release and local tag identify v0.3.10 at the pinned main SHA. The branch's 0.3.11 changelog is release preparation, not evidence of publication. The lockfile adds only a direct reference to already-locked esbuild 0.28.2; existing workspace policy already permits its build. Publishing workflows, permissions, package sources, and lifecycle scripts are unchanged. (package.json:3, c6e79655ca1d)
  • Area history and inspection limits: Available main history records Peter Steinberger's runtime and request-lifecycle work and Sebastien Tardif's forward/CONNECT cancellation work. Deeper follow-history, blame, and exact historical patches encountered unavailable objects and network resolution failures, so no source-line introduction attribution is asserted. Live GitHub listing also failed; the supplied complete discussion, checks, and previous-review projection remain the review context. (src/node-http.ts, 24bfeb6ed96a)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Sebastien Tardif: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-06T20:31:28.938Z sha f6f0958 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T20:43:32.314Z sha 27fbaa9 :: needs maintainer review before merge. :: none
@steipete steipete changed the title fix(runtime): preserve standalone bundles with installed Undici Sep 6, 2026
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review final head 27fbaa9. The previous completed review covers f6f0958 only. The final head also preserves caller-supplied cancellation errors in both pending request paths, with two fresh failing-before/passing-after regressions on Node and Bun. The body contains the exact-head commands/output and the independent full-upgrade source assessment. Exact-head CI 34058623167 and package verification 34058623256 are green.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 6, 2026
@steipete
steipete merged commit a8dafd8 into main Sep 6, 2026
20 checks passed
@vincentkoc
vincentkoc deleted the codex/bun-bundle-safe-undici branch September 25, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

1 participant