Skip to content

fix(runtime): load installed Undici peer under Bun - #31

Merged
steipete merged 1 commit into
mainfrom
codex/bun-installed-undici
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/bun-installed-undici

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Bun substitutes its compatibility module for a bare undici import. Proxyline consequently captures a different fetch class family and a dispatcher without the lifecycle methods it calls. Two existing package-entrypoint tests fail under Bun during fetch-global installation and shutdown.

Change

Resolve the installed Undici peer relative to Proxyline, then load its package entry point. The peer remains shared with the host, and proxy routing, request normalization, assertions, and public APIs are unchanged. Prepare the approved 0.3.10 patch release and preserve the next-version Unreleased changelog section.

Validation

  • Before: two data-only entrypoint cases pass on Node and fail on Bun.
  • After: five existing selected entrypoint cases pass on Node 26.8.1 and Bun 1.4.2, covering fetch-global restoration, multipart encoding, ordinary loopback proxy redirect semantics, replaced request bodies, and streaming request bodies.
  • Build/typecheck, package-artifact validation, and docs build pass.
  • Other policy/TLS/adversarial cases were not run locally; the existing Node CI matrix remains required before release. This fixes the installed-peer loading boundary and does not claim complete Bun compatibility.

Exact-commit runtime evidence

Verified commit cd68dac9c7f5dd2c367417d74f55e7305cf5f413, package 0.3.10, installed Undici peer 8.10.1, Node 26.8.1, Bun 1.4.2. Rebuilt dist at this commit before these runs. Both commands exited 0; the processes completed without cleanup errors. The first case asserts replacement and restoration of all five fetch globals; the final three use the real owned loopback proxy lab and assert response status/body and proxy activity.

pnpm build
pattern='^package entrypoint (patches and restores fetch globals together|global fetch encodes FormData as multipart|preserves standard options on preinstall Requests|lets fetch init body replace a consumed preinstall Request body|streams preinstall Request bodies without buffering first)$'
node --import tsx --test --test-name-pattern="$pattern" test/package.test.ts
bun test --test-name-pattern="$pattern" test/package.test.ts

Actual Bun output:

bun test v1.4.2 (744846f84)

test/package.test.ts:
(pass) package entrypoint patches and restores fetch globals together [4.48ms]
(pass) package entrypoint global fetch encodes FormData as multipart [0.76ms]
(pass) package entrypoint preserves standard options on preinstall Requests [22.89ms]
(pass) package entrypoint lets fetch init body replace a consumed preinstall Request body [6.98ms]
(pass) package entrypoint streams preinstall Request bodies without buffering first [10.22ms]

 5 pass
 3 filtered out
 0 fail
Ran 5 tests across 1 file. [208.00ms]

Node output likewise reports the same five names passed, tests 5, pass 5, fail 0, cancelled 0, skipped 0, with duration 366.526333ms.

The full nine-job Node coverage matrix and package verification passed on this head. Local filtered proof is deliberately distinguished from the complete Node CI suite.

Minimum-peer artifact check: packed this commit as @openclaw/proxyline@0.3.10, installed the tarball into an isolated consumer with exactly undici@8.5.0, and ran the same in-memory install/fetch/restore probe with an empty inherited environment. The probe asserts all four fetch constructors equal the installed peer, successfully reads two data URLs (including a pre-install Request), then asserts every captured global and the original peer dispatcher are restored. No socket is opened. Both processes exited 0:

{"runtime":"Node 26.8.1","proxyline":"0.3.10","sharedPeer":true,"fetchAndRestore":true}
{"runtime":"Bun 1.4.2","proxyline":"0.3.10","sharedPeer":true,"fetchAndRestore":true}
@steipete
steipete requested a review from a team as a code owner September 6, 2026 19:03
@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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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, 3:14 PM ET / 19:14 UTC.

ClawSweeper review

What this changes

Load Proxyline’s installed Undici peer explicitly for compatible fetch classes and dispatcher cleanup under Bun, document the behavior, and prepare version 0.3.10.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on the reviewed main branch. The updated evidence satisfies the previous proof request, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: cd68dac9c7f5dd2c367417d74f55e7305cf5f413

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused compatibility repair with relevant recorded runtime proof and no actionable introduced defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): At the reviewed SHA, recorded Bun output exercises the built package’s fetch installation, real loopback requests, and cleanup; isolated packed-consumer output also verifies shared-peer identity and restoration with Undici 8.5.0 on Node and Bun. This satisfies the prior proof request without claiming complete Bun compatibility.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): At the reviewed SHA, recorded Bun output exercises the built package’s fetch installation, real loopback requests, and cleanup; isolated packed-consumer output also verifies shared-peer identity and restoration with Undici 8.5.0 on Node and Bun. This satisfies the prior proof request without claiming complete Bun compatibility.
Evidence reviewed 7 items Verified introduced change: The local diff matches the complete host-provided introduction evidence: four files change, with runtime edits confined to loading the installed peer and using its constructors. Repository origin identifies openclaw/proxyline.
Main and latest release still use the bare import: Both fetched main and the supplied latest release, v0.3.9, import runtime values directly from undici. The installed-peer resolution is absent from both; no verified merged replacement was supplied. The supplementary GitHub canonical search could not complete because network access failed.
Updated proof resolves the prior request: The complete supplied body, captured with sourceRevision 0c0b91b2ad6b684f55c03268f1b6ca8777e6ddc693e859bd20029d57fe585255, records the reviewed SHA, Node 26.8.1, Bun 1.4.2, Undici 8.10.1, exact commands, and five passing Bun cases with no cleanup errors. It also records an isolated packed-consumer check using Undici 8.5.0 on both runtimes, with shared-peer identity and fetch/restoration assertions passing. This addresses the concrete request retained from #31 (comment).
Findings None None.
Security None None.

How this fits together

Proxyline routes a process’s HTTP and fetch requests through configured proxies. Its runtime installs compatible fetch globals and dispatchers, then restores the previous globals and releases its transports when stopped.

flowchart TD
  A[Host application] --> B[Proxyline runtime]
  C[Installed Undici peer] --> B
  D[Proxy configuration] --> B
  B --> E[Fetch globals and dispatcher]
  E --> F[Direct or proxied requests]
  B --> G[Stop and restore globals]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta Production +28/-16 (net +12); tests +0/-0 The small runtime increase explicitly resolves the installed peer, with existing package cases used for behavioral validation.

Technical review

Best possible solution:

Keep one installed Undici implementation responsible for fetch classes and dispatcher lifecycle while preserving the existing routing and restoration contracts.

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

Yes, the report identifies two existing package-entrypoint cases that fail under Bun before the fix, and source inspection locates the bare-import boundary; the reviewer did not independently execute the failing baseline.

Is this the best way to solve the issue?

Yes, explicit peer resolution is a narrow repair that preserves the existing API and routing logic; the supplied Node, Bun, and minimum-peer results support compatibility.

AGENTS.md: not found in the target repository.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. At the reviewed SHA, recorded Bun output exercises the built package’s fetch installation, real loopback requests, and cleanup; isolated packed-consumer output also verifies shared-peer identity and restoration with Undici 8.5.0 on Node and Bun. This satisfies the prior proof request without claiming complete Bun compatibility.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • remove status: 📣 needs proof: Current PR status no longer selects a status label.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded runtime-compatibility repair for Bun, without evidence of an urgent regression in the supported Node workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • proof: sufficient: Contributor real behavior proof is sufficient. At the reviewed SHA, recorded Bun output exercises the built package’s fetch installation, real loopback requests, and cleanup; isolated packed-consumer output also verifies shared-peer identity and restoration with Undici 8.5.0 on Node and Bun. This satisfies the prior proof request without claiming complete Bun compatibility.

Evidence

What I checked:

  • Verified introduced change: The local diff matches the complete host-provided introduction evidence: four files change, with runtime edits confined to loading the installed peer and using its constructors. Repository origin identifies openclaw/proxyline. (src/runtime.ts:46, cd68dac9c7f5)
  • Main and latest release still use the bare import: Both fetched main and the supplied latest release, v0.3.9, import runtime values directly from undici. The installed-peer resolution is absent from both; no verified merged replacement was supplied. The supplementary GitHub canonical search could not complete because network access failed. (src/runtime.ts:7, 49a787d39a4f)
  • Updated proof resolves the prior request: The complete supplied body, captured with sourceRevision 0c0b91b2ad6b684f55c03268f1b6ca8777e6ddc693e859bd20029d57fe585255, records the reviewed SHA, Node 26.8.1, Bun 1.4.2, Undici 8.10.1, exact commands, and five passing Bun cases with no cleanup errors. It also records an isolated packed-consumer check using Undici 8.5.0 on both runtimes, with shared-peer identity and fetch/restoration assertions passing. This addresses the concrete request retained from fix(runtime): load installed Undici peer under Bun #31 (comment). (cd68dac9c7f5)
  • Proof exercises the production package: The inspected cases import dist/index.js, install the real runtime, assert fetch-global restoration, and exercise redirects and request bodies through real loopback servers. The proxy lab uses HTTP servers and actual upstream requests, not mocked transport clients. (test/package.test.ts:4, cd68dac9c7f5)
  • Existing contract and dependency boundary: The documented contract already replaces fetch constructors with the peer’s implementations and restores previous globals on stop. package.json continues to require undici >=8.5.0 <9. The explicit dependency signal is src/runtime.ts resolving undici/package.json and loading its index.js; the supplied minimum-peer artifact proof directly covers that package-layout assumption. (src/runtime.ts:62, cd68dac9c7f5)
  • Feature-history routing: Available main-branch history identifies Peter Steinberger’s repeated runtime work and Jesse Merhi’s managed-fetch change. Older source blobs were unavailable and could not be fetched, so exact line-introduction attribution was not established; routing candidates remain unverified. (src/runtime.ts, 49a787d39a4f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jesse Merhi: 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 (1 earlier review cycle)
  • reviewed 2026-09-06T19:05:26.720Z sha cd68dac :: needs real behavior proof before merge. :: none
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes the exact reviewed SHA, runtime/peer versions, reproduction commands, and inspected Bun output showing all five selected built-package cases pass with exit 0. It also records a packed-artifact check with the minimum supported Undici 8.5.0 peer on Node and Bun. The source head is unchanged; this addresses the missing inspectable proof in the previous review.

@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:

@steipete
steipete merged commit c6e7965 into main Sep 6, 2026
21 checks passed
@vincentkoc
vincentkoc deleted the codex/bun-installed-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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

1 participant