Skip to content

fix(world-vercel): skip Dispatcher.compose() when undici can't compose (Bun) - #4557

Merged
VaguelySerious merged 3 commits into
vercel:mainfrom
SandboxRD:fix/world-vercel-bun-compose
Oct 1, 2026
Merged

VaguelySerious merged 3 commits into
vercel:mainfrom
SandboxRD:fix/world-vercel-bun-compose

Conversation

@SandboxRD

Copy link
Copy Markdown
Contributor

Fixes #4555.

Problem

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(). Two factories in @workflow/world-vercel call compose() and throw:

Bun's fetch also ignores the dispatcher option. I checked by passing a dispatcher whose dispatch() throws, and fetch went straight to the server. So under Bun there's nothing for an interceptor to wrap.

Fix

Add supportsCompose(dispatcher), which checks whether compose is a function, and skip composing when it isn't:

  • Queue path: the RetryAgent wraps the plain Agent.
  • Events path: return the RetryAgent without the H2 multiplex interceptor. This is the same shape as the existing WORKFLOW_H2_MULTIPLEX=0 branch.

Node behavior doesn't change: there, compose exists 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's fetch never consults the dispatcher. I noted it in the supportsCompose doc comment.

Tests

  • New src/http-client-bun.test.ts mocks undici with Bun-style stub classes (no compose, no dispatch) 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.
  • Whole package on Node 24.21: 847/849. The two failures are in http-core.test.ts ({"Connection":"invalid"} request-validation cases). They fail identically on main without this change on my machine, so they look environmental.

Checked under real Bun

I ran the repro from #4555 against this branch's built dist on Bun 1.3.11:

bun 1.3.11 | typeof new Agent().compose: undefined
createQueueDispatcher: ok
createEventsDispatcher: ok
createStreamDispatcher: ok
getQueueDispatcher: ok
getEventsDispatcher: ok

Before the fix, createQueueDispatcher and createEventsDispatcher both threw.

A changeset is included (@workflow/world-vercel patch).

🤖 Generated with Claude Code

…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>
@SandboxRD
SandboxRD requested a review from a team as a code owner October 1, 2026 16:03
@changeset-bot

changeset-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 642e639

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@workflow/world-vercel Patch
@workflow/cli Patch
@workflow/core Patch
@workflow/web Patch
workflow Patch
@workflow/world-testing Patch
@workflow/builders Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/nuxt Patch

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

@vercel

vercel Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@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 VaguelySerious left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review: no blocking issues

Comment thread packages/world-vercel/src/http-client.ts Outdated
Comment thread packages/world-vercel/src/http-client-bun.test.ts Outdated
… 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>
@VaguelySerious

Copy link
Copy Markdown
Member

One more thing, could you make this check pass? https://github.com/vercel/workflow/pull/4557/checks?check_run_id=110513913363

I, SandboxRD <ray@sandboxwealth.com>, hereby add my Signed-off-by to this commit: f31de9f
I, SandboxRD <ray@sandboxwealth.com>, hereby add my Signed-off-by to this commit: 5c79960

Signed-off-by: SandboxRD <ray@sandboxwealth.com>
@VaguelySerious

Copy link
Copy Markdown
Member

Or ask your agent to do a DCO sign-off on this PR

@VaguelySerious

Copy link
Copy Markdown
Member

Just saw you did that as I was commenting, thanks

@VaguelySerious
VaguelySerious merged commit 6eaa899 into vercel:main Oct 1, 2026
118 of 181 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 1, 2026
github-actions Bot added a commit that referenced this pull request Oct 1, 2026
…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>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Backport PR opened against stable: #4567. Merge conflicts were resolved by AI — please review carefully. (backport job run)

VaguelySerious pushed a commit that referenced this pull request Oct 1, 2026
…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>
@github-actions github-actions Bot mentioned this pull request Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

world-vercel: createQueueDispatcher crashes under Bun (Agent.compose is not a function), breaking SvelteKit builds since 4.7.4

2 participants