Auto-fix CI failures for PR #1375 - #1381
Conversation
undici >= 8 destructures markAsUncloneable from node:worker_threads without a fallback. Bun (the Docker build stage runtime) does not implement this Node.js 23+ API, so webidl.util.markAsUncloneable is undefined and next build crashes during page-data collection for the /v1 and /v1beta proxy routes. Add a side-effect polyfill that defines markAsUncloneable as a no-op when it is missing, restoring the safe fallback that undici 7.x shipped. The guard ensures the real Node.js implementation is used unchanged in production. Verified: bun run build passes with undici 8.9.0 installed (the failing scenario). typecheck and lint clean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de49db97dc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| @@ -1,4 +1,5 @@ | |||
| import "@/lib/polyfills/file"; | |||
| import "@/lib/polyfills/worker-threads"; | |||
There was a problem hiding this comment.
Load the undici polyfill before legacy action imports
When the Bun/undici>=8 workaround is needed, limiting this side-effect import to /v1//v1beta still leaves the legacy actions route unpatched: src/app/api/actions/[...route]/route.ts imports @/actions/providers at module load, which pulls @/lib/proxy-agent and imports undici before markAsUncloneable is installed. The Docker build runs bun run build, so after /v1 is fixed it can still hit the same webidl.util.markAsUncloneable crash while evaluating /api/actions; move/import the polyfill from a shared server bootstrap or add it ahead of those action imports too.
Useful? React with 👍 / 👎.
cf80980 to
e4d7030
Compare
Summary
Fixes the Docker Build Test job failure in the PR Build Check workflow (run 30714661886) for PR #1375.
markAsUncloneableno-op polyfill onnode:worker_threadsso undici >= 8 can be imported under Bun during the Docker build stage./v1and/v1betaproxy route entry points (right after the existing@/lib/polyfills/fileimport), ahead of any transitive undici import.Root cause
The failing error is:
during
next buildpage-data collection for/v1/[...route].lib/web/webidlshipped a safe fallback:webidl.util.markAsUncloneable = markAsUncloneable || (() => {}).const { markAsUncloneable } = require('node:worker_threads').node:worker_threads.markAsUncloneableis a Node.js 23+ API that Bun's JSC runtime does not implement, so under Bun the destructured binding isundefinedand constructing any undici Web API object throws.bun run buildonoven/bun:debian, which is why CI hit this while local Node builds did not.This regression originates from dev's dependency bump in #1376 (
undici: ^7->^8.9.0). It is not caused by anything in PR #1375's own code.Verification
bun run typecheck(tsgo) — cleanbun run lint(biome) — clean (2 pre-existing biome.json deprecation infos, unrelated)bun run lint:fix— no fixes appliedbun run buildwith undici 8.9.0 installed (the exact failing scenario) — exit 0, route table renders/v1/[...route]and/v1beta/[...route]successfullygit diff --check— cleanThe polyfill guard (
typeof ... !== "function") ensures the real Node.jsmarkAsUncloneableis used unchanged in production; the no-op only applies where the API is missing (the Bun build stage), matching the previous undici 7.x behavior exactly.Notes for review — repo-wide regression on dev
The undici ^8.9.0 bump (dev commit 519c605, #1376) breaks the Bun-based Docker build repo-wide: dev's own "PR Build Check" is currently failing on the same error (run 30712055253, "release v0.9.1"). This PR unblocks #1375 in isolation, but the underlying dependency incompatibility should ideally be resolved on dev as well (a separate auto-fix branch,
claude-fix-pr-1379-30714202270, applies the same polyfill approach for another affected PR).This polyfill is a safe, surgical workaround with no behavior change and no dependency-version change, so it will not conflict with dev's
undici: ^8.9.0on merge.Test plan
bun run typecheckpassesbun run lint/lint:fixpassbun run buildpasses with undici 8.9.0 (reproduces and resolves the CI failure)Greptile Summary
The PR adds a guarded
node:worker_threads.markAsUncloneablecompatibility polyfill and loads it before the proxy routes’ undici dependency graph./v1and/v1betaroute entrypoints.Confidence Score: 5/5
The PR appears safe to merge, with no concrete changed-code failure identified.
The guarded shim leaves native implementations unchanged, and the affected Node.js route entrypoints evaluate it before their undici-dependent proxy modules.
Important Files Changed
worker_threads.markAsUncloneable./v1proxy route’s undici-dependent imports./v1betaproxy route’s undici-dependent imports.Reviews (1): Last reviewed commit: "fix(build): polyfill markAsUncloneable f..." | Re-trigger Greptile
Context used: