Skip to content

fix(build): revert undici to ^7 (Bun build incompatibility) - #1378

Closed
github-actions[bot] wants to merge 1 commit into
chore/typescript-7-latest-depsfrom
claude-fix-pr-1376-30711938633
Closed

fix(build): revert undici to ^7 (Bun build incompatibility)#1378
github-actions[bot] wants to merge 1 commit into
chore/typescript-7-latest-depsfrom
claude-fix-pr-1376-30711938633

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

CI Auto-Fix

Original PR: #1376 (chore/typescript-7-latest-deps)
Failed CI Run: PR Build Check - Docker Build Test

Root Cause

The Docker build (bun run build, build stage oven/bun:debian) fails during Next.js "Collecting page data":

TypeError: s.util.markAsUncloneable is not a function
Error: Failed to collect page data for /v1/[...route]

undici 8.x (lib/web/webidl/index.js) unconditionally destructures markAsUncloneable from node:worker_threads:

const { markAsUncloneable } = require('node:worker_threads')  // undefined under Bun

node:worker_threads.markAsUncloneable does not exist in Bun (confirmed: typeof is undefined), and the build runs under Bun. undici is imported directly by the proxy route (forwarder.ts, available-models.ts, gemini/auth.ts), so it is evaluated at build time, and a constructor calls the undefined function.

The runtime stage (node:trixie-slim, Node 24+) would have the symbol, but the build never reaches it.

Fix Applied

File Change Reason
package.json undici: ^8.9.0 -> ^7 undici 7.x guards markAsUncloneable behind a runtime-feature check with a no-op fallback, loading cleanly under Bun. All APIs the proxy uses (Agent, ProxyAgent, request, fetch, setGlobalDispatcher) are present in 7.x.

This restores the exact dependency state that was green before the upgrade commit, with no application-logic changes.

Verification

  • bun install resolves undici@7.29.0
  • require('undici') loads under Bun without throwing; all used exports present
  • bun run build exits 0 locally (tsgo typecheck + next build page-data collection for /v1/[...route] now succeeds + post-build copy scripts)

Re-upgrading to undici 8

This should be retried once one of the following holds:

  • Bun ships markAsUncloneable in its node:worker_threads polyfill, or
  • The Docker build stage switches to Node >= 23 (which has the symbol).

Notes

  • Not auto-fixable by the original PR: the remaining Edge-Runtime warnings in the log (process.*, node:crypto, node:net in instrumentation.ts / session-binding.ts / extract-client-ip.ts / private-ip.ts) are warnings only and did not fail the build.
  • No logic/behavior changes; scope limited to the single dependency version that caused the hard build failure.

Auto-generated by Claude AI

Greptile Summary

This PR restores Bun build compatibility by downgrading the declared undici dependency from 8.9.x to the latest compatible 7.x release.

  • Reverts the dependency major version to avoid undici 8's unsupported worker_threads.markAsUncloneable usage under Bun.
  • Preserves the undici APIs currently consumed by the proxy and networking code.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete regressions identified in the dependency downgrade.

The repository intentionally performs non-frozen installs without a committed lockfile, and all undici APIs used by current call sites remain available in version 7.

Important Files Changed

Filename Overview
package.json Downgrades undici from ^8.9.0 to ^7; existing install behavior and repository API usage are compatible with the change.

Reviews (1): Last reviewed commit: "fix(build): revert undici to ^7 (incompa..." | Re-trigger Greptile

undici 8.x unconditionally destructures `markAsUncloneable` from
`node:worker_threads` (lib/web/webidl/index.js), but Bun's
`node:worker_threads` does not export that symbol. Since the Docker
build stage runs `bun run build`, undici is evaluated under Bun during
Next.js "Collecting page data" for /v1/[...route], throwing:

  TypeError: s.util.markAsUncloneable is not a function
  Error: Failed to collect page data for /v1/[...route]

undici 7.x guards the same call behind a runtime-feature check and
falls back to a no-op, so it loads cleanly under Bun while preserving
every API the proxy uses (Agent, ProxyAgent, request, fetch,
setGlobalDispatcher).

Re-upgrading to undici 8 should wait until either Bun ships
`markAsUncloneable` or the build stage switches to Node >= 23.

CI Run: https://github.com/ding113/claude-code-hub/actions/runs/30711830763

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant