Repository navigation
fix(world-vercel): skip Dispatcher.compose() when undici can't compose (Bun) - #4557
Conversation
…e (Bun)
Under Bun, `import { Agent } from 'undici'` resolves to Bun's built-in
module, whose dispatchers have no compose() or dispatch(), and Bun's
fetch ignores the dispatcher option. createQueueDispatcher() and
createEventsDispatcher() threw "compose is not a function" there.
Feature-detect compose() and use the plain dispatcher when it's missing.
Fixes vercel#4555
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 642e639 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@SandboxRD is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
VaguelySerious
left a comment
There was a problem hiding this comment.
AI review: no blocking issues
… Bun test Under Bun every undici dispatcher option is inert, not only the interceptors, so a hung queue request is bounded by Bun's own 300s fetch default rather than QUEUE_REQUEST_TIMEOUT_MS. Document that and the runtime-neutral fix (an AbortSignal inside @vercel/queue). The Bun test now asserts the events dispatcher is a bare RetryAgent around an Agent instead of only that it doesn't throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One more thing, could you make this check pass? https://github.com/vercel/workflow/pull/4557/checks?check_run_id=110513913363 |
|
Or ask your agent to do a DCO sign-off on this PR |
|
Just saw you did that as I was commenting, thanks |
…e (Bun) (#4557) Fixes #4555. Under Bun, `import { Agent } from 'undici'` resolves to Bun's built-in `undici` module even when the `undici` package is installed. Its dispatcher classes are stubs: they have no `compose()` and no `dispatch()` Signed-off-by: SandboxRD <ray@sandboxwealth.com> Signed-off-by: Ray Denis <ray@sandboxwealth.com>
|
Backport PR opened against |
…ici can't compose (Bun) (#4567) Automated backport of #4557 to `stable` ([backport job run](https://github.com/vercel/workflow/actions/runs/36908102451)). Signed-off-by: SandboxRD <ray@sandboxwealth.com> Signed-off-by: Ray Denis <ray@sandboxwealth.com> Signed-off-by: Peter Wielander <mittgfu@gmail.com>
Fixes #4555.
Problem
Under Bun,
import { Agent } from 'undici'resolves to Bun's built-inundicimodule even when theundicipackage is installed. Its dispatcher classes are stubs: they have nocompose()and nodispatch(). Two factories in@workflow/world-vercelcallcompose()and throw:createQueueDispatcher():new Agent(...).compose is not a function. This is the one reported in world-vercel: createQueueDispatcher crashes under Bun (Agent.compose is not a function), breaking SvelteKit builds since 4.7.4 #4555.createEventsDispatcher():agent.compose is not a function. It's on the default HTTP/2 path (WORKFLOW_H2_MULTIPLEXunset), so the events path breaks under Bun too.Bun's
fetchalso ignores thedispatcheroption. I checked by passing a dispatcher whosedispatch()throws, andfetchwent straight to the server. So under Bun there's nothing for an interceptor to wrap.Fix
Add
supportsCompose(dispatcher), which checks whethercomposeis a function, and skip composing when it isn't:RetryAgentwraps the plainAgent.RetryAgentwithout the H2 multiplex interceptor. This is the same shape as the existingWORKFLOW_H2_MULTIPLEX=0branch.Node behavior doesn't change: there,
composeexists and both paths compose exactly as before.One known gap: under Bun, the queue path's 30s deadline (
deadlineInterceptor) doesn't apply. That's already true today wherever it doesn't crash, because Bun'sfetchnever consults the dispatcher. I noted it in thesupportsComposedoc comment.Tests
src/http-client-bun.test.tsmocksundiciwith Bun-style stub classes (nocompose, nodispatch) and builds the queue dispatcher and both events dispatcher variants.src/http-client.test.ts: 49/49 pass on Node 24.21, so the composed Node path is unchanged.http-core.test.ts({"Connection":"invalid"}request-validation cases). They fail identically onmainwithout this change on my machine, so they look environmental.Checked under real Bun
I ran the repro from #4555 against this branch's built
diston Bun 1.3.11:Before the fix,
createQueueDispatcherandcreateEventsDispatcherboth threw.A changeset is included (
@workflow/world-vercelpatch).🤖 Generated with Claude Code