Skip to content

Backport #1853: [core] Add wire-level framing for byte streams#2380

Merged
VaguelySerious merged 4 commits into
stablefrom
backport/pr-1853-to-stable
Jun 15, 2026
Merged

Backport #1853: [core] Add wire-level framing for byte streams#2380
VaguelySerious merged 4 commits into
stablefrom
backport/pr-1853-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #1853 to stable (backport job run).

AI recommendation: Self-contained minor feature in @workflow/core whose prerequisites all exist on stable: I verified capabilities.ts, healthCheck() with workflowCoreVersion (the #1854 dependency), serialization.ts, and the related object-stream reconnect infrastructure (reconnecting-framed-stream) are all present on origin/stable. It also lays groundwork for byte-stream auto-reconnect, complementing the reconnect work already on stable (#1847). Note for reviewers: the framedByteStreams capability cutoff is 5.0.0-beta.15 (a main-only version), so a stable backport should adjust the minVersion to the appropriate 4.x release; main's serialization/types.ts changes also need mapping onto stable's single-file serialization.ts layout.

Merge conflicts were resolved by AI (opencode with anthropic/claude-fable-5). Please review the conflict resolution carefully before merging.

Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Signed-off-by: Nathan Rajlich <n@n8.io>
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1094d35

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

This PR includes changesets to release 17 packages
Name Type
@workflow/core Minor
workflow Minor
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web Patch
@workflow/world-testing Patch
@workflow/ai Major
@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 Jun 12, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jun 15, 2026 3:10pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jun 15, 2026 3:10pm
example-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-astro-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-express-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-fastify-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-hono-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-nitro-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-nuxt-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workbench-vite-workflow Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Jun 15, 2026 3:10pm
workflow-swc-playground Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workflow-tarballs Ready Ready Preview, Comment Jun 15, 2026 3:10pm
workflow-web Ready Ready Preview, Comment Jun 15, 2026 3:10pm

Comment thread packages/core/src/capabilities.ts Outdated
…-beta.15'` on the `stable` (4.x) branch, so the gate is always `false` and the feature is dead code on every stable run.

This commit fixes the issue reported at packages/core/src/capabilities.ts:88

## Bug

In `packages/core/src/capabilities.ts`, the `CAPABILITY_VERSION_TABLE` gated `framedByteStreams` on:

```ts
}> = [{ capability: 'framedByteStreams', minVersion: '5.0.0-beta.15' }];
```

`getRunCapabilities()` enables the capability via `semver.gte(workflowCoreVersion, minVersion)`. `workflowCoreVersion` is the run's recorded `@workflow/core` version, generated from `package.json`.

This is a **backport of #1853 to the `stable` branch**:
- `packages/core/package.json` → `"version": "4.4.0"`
- `.changeset/byte-stream-wire-framing.md` is a `minor` bump for `@workflow/core` → next stable release is `4.5.0`

Every run on the stable line therefore records a `4.x.y` version. For any `4.x.y`, the major version `4 < 5`, so `semver.gte('4.x.y', '5.0.0-beta.15')` is **always `false`**. The capability can never become `true` on stable.

### Manifestation / trigger

For any run created on the stable line (concrete trigger: a run with recorded version e.g. `4.5.0`):
- `resume-hook.ts` passes `capabilities.framedByteStreams` → always `false` → resume payloads never frame.
- Cross-deployment `start()` in `start.ts` probes the target version, sees `4.x` → `false` → writes raw bytes.

So the backported capability detection is silently inert; framing only ever activates on the hardcoded-`true` paths (same-deployment start, step return values, getWritable). This is a functional gap (not data corruption — a too-high cutoff is the "safe" direction per the table's `TODO(release)` comment), but it makes the cross-deployment/resume framing path dead code on stable.

## Fix

Set the cutoff to the actual stable release version that ships this change:

```ts
}> = [{ capability: 'framedByteStreams', minVersion: '4.5.0' }];
```

Also updated the `## History` doc comment (`added in 4.5.0`) and the version-gate unit tests in `capabilities.test.ts`, which were still written against the v5 beta cutoff and would otherwise fail:
- pre-framing (false): `4.2.0-beta.64`, `4.2.0`, `4.4.0`, `4.5.0-beta.14`
- exact cutoff (true): `4.5.0`
- post-framing (true): `4.5.1`, `4.6.0`, `5.0.0`, `6.0.0`

These are consistent with semver semantics (a prerelease like `4.5.0-beta.14` is `< 4.5.0`, and all `>= 4.5.0` including future majors satisfy the gate).

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: VaguelySerious <mittgfu@gmail.com>
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1044 0 67 1111
✅ 💻 Local Development 1126 0 86 1212
✅ 📦 Local Production 1126 0 86 1212
✅ 🐘 Local Postgres 1114 0 98 1212
✅ 🪟 Windows 101 0 0 101
❌ 🌍 Community Worlds 76 97 6 179
✅ 📋 Other 568 0 38 606
Total 5155 97 381 5633

❌ Failed Tests

🌍 Community Worlds (97 failed)

redis (18 failed):

  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KV5X8AC89H41A4WHNBS320G6
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KV5X8QZM2P84SWXZAT64FSK4
  • sleepingWorkflow | wrun_01KV5XA6GY6DD0GVYYPED3H0SX
  • outputStreamWorkflow negative startIndex (reads from end)
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns correct index after stream completes
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns -1 before any chunks are written
  • outputStreamWorkflow - getTailIndex and getStreamChunks getStreamChunks returns same content as reading the stream
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KV5XJQCC4VW2VEVNSRBRY9CW
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KV5XK4FBH6B5XJE0MXY58T7V
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KV5XKC4GS4XDEKQ0YJY715PS
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KV5XKTWAAQS66QF0WDW91WYD
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KV5XMQ26WJ60A97HXGY81CVF
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KV5XMW8274KKGA5XM2V032BM
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KV5XN2XB54ZAYY827EHTA2ZS
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KV5XN8V9ZFZ28XQF2P1WY5H7
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KV5XNHWCHJHK45GYFGKYPD76
  • pages router sleepingWorkflow via pages router
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KV5XVM7D05NYPTH0W242GS66

turso (79 failed):

  • addTenWorkflow | wrun_01KV5X6XNJNXWSFM3V0WKS068S
  • addTenWorkflow | wrun_01KV5X6XNJNXWSFM3V0WKS068S
  • wellKnownAgentWorkflow (.well-known/agent) | wrun_01KV5X7ZVHAS22EZD1RAVFMJYE
  • should work with react rendering in step
  • promiseAllWorkflow | wrun_01KV5X7710BD1A7VFDKTDRXDSZ
  • promiseRaceWorkflow | wrun_01KV5X7CXRKBJAXQ0WET9AW6WS
  • promiseAnyWorkflow | wrun_01KV5X7GBM9TADMN44Q4S8H01A
  • importedStepOnlyWorkflow | wrun_01KV5X8C237YWSTK6MMZSF3FCR
  • readableStreamWorkflow | wrun_01KV5X7KYGG3SM83YJ2KXF1463
  • hookWorkflow | wrun_01KV5X81CARXDPMQW3JHBE34VY
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KV5X8AC89H41A4WHNBS320G6
  • webhookWorkflow | wrun_01KV5X8JEPEP4AS3Z0PKA615AP
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KV5X8QZM2P84SWXZAT64FSK4
  • sleepingWorkflow | wrun_01KV5XA6GY6DD0GVYYPED3H0SX
  • parallelSleepWorkflow | wrun_01KV5XAPH4E1H0QQEZ9MK1JBHH
  • nullByteWorkflow | wrun_01KV5XASZRENJ365VW9QX1CB1M
  • workflowAndStepMetadataWorkflow | wrun_01KV5XAXMKYF81ZCN8S4W7GRW8
  • outputStreamWorkflow no startIndex (reads all chunks)
  • outputStreamWorkflow positive startIndex (skips first chunk)
  • outputStreamWorkflow negative startIndex (reads from end)
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns correct index after stream completes
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns -1 before any chunks are written
  • outputStreamWorkflow - getTailIndex and getStreamChunks getStreamChunks returns same content as reading the stream
  • outputStreamInsideStepWorkflow - getWritable() called inside step functions | wrun_01KV5XDPZ9ET10YHG0T0AXQ9VD
  • writableForwardedFromWorkflowWorkflow | wrun_01KV5XE5KX5VWE8J8R4N8Q4ZHZ
  • writableForwardedFromStepWorkflow | wrun_01KV5XECT96CWBWP7DKR2WE8QB
  • fetchWorkflow | wrun_01KV5XEHF1EWW0764P8KGZCC7J
  • promiseRaceStressTestWorkflow | wrun_01KV5XEMYCYJ61BZ16GBQWFJ23
  • error handling error propagation workflow errors nested function calls preserve message and stack trace
  • error handling error propagation workflow errors cross-file imports preserve message and stack trace
  • error handling error propagation step errors basic step error preserves message and stack trace
  • error handling error propagation step errors cross-file step error preserves message and function names in stack
  • error handling retry behavior regular Error retries until success
  • error handling retry behavior FatalError fails immediately without retries
  • error handling retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • error handling not registered WorkflowNotRegisteredError fails the run when workflow does not exist
  • error handling not registered StepNotRegisteredError fails the step but workflow can catch it
  • error handling not registered StepNotRegisteredError fails the run when not caught in workflow
  • hookCleanupTestWorkflow - hook token reuse after workflow completion | wrun_01KV5XJ9YKCSNX0QMD2XWRD5R0
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KV5XJQCC4VW2VEVNSRBRY9CW
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KV5XK4FBH6B5XJE0MXY58T7V
  • 'hookGetConflictWithPriorStepWorkflow' - hook.getConflict() does not block step execution | wrun_01KV5XK6XNMEVBY1KAE1FZT9AV
  • 'hookGetConflictWithParallelStepWorkfl…' - hook.getConflict() does not block step execution | wrun_01KV5XK9FTC57BZFKWS7Y0WGHH
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KV5XKC4GS4XDEKQ0YJY715PS
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KV5XKTWAAQS66QF0WDW91WYD
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KV5XMQ26WJ60A97HXGY81CVF
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KV5XMW8274KKGA5XM2V032BM
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KV5XN2XB54ZAYY827EHTA2ZS
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KV5XN8V9ZFZ28XQF2P1WY5H7
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KV5XNHWCHJHK45GYFGKYPD76
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running | wrun_01KV5XNSGJMSF25JK51CPJ6WNY
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars) | wrun_01KV5XP9GCRJCZXF7WC41HAZPZ
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument | wrun_01KV5XPK0XJJ2A04E8Y7B80Q65
  • closureVariableWorkflow - nested step functions with closure variables | wrun_01KV5XPS9862NKEJJ0M1GFMREY
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step | wrun_01KV5XPVMGVKG7KAQZRFWBDW75
  • health check (queue-based) - workflow and step endpoints respond to health check messages
  • health check (CLI) - workflow health command reports healthy endpoints
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly | wrun_01KV5XQCE48JBCH3P00X0NX5TD
  • Calculator.calculate - static workflow method using static step methods from another class | wrun_01KV5XQJDQBMS2N79KA9BPJ5KX
  • AllInOneService.processNumber - static workflow method using sibling static step methods | wrun_01KV5XQSCXSKJ4FFCFAWQS55VP
  • ChainableService.processWithThis - static step methods using this to reference the class | wrun_01KV5XR0C3B6PRMKPB09SC2VT3
  • thisSerializationWorkflow - step function invoked with .call() and .apply() | wrun_01KV5XR7BQB38T1GA9P7DGSAZS
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE | wrun_01KV5XRFJ566H6GYM908V8Z7FD
  • instanceMethodStepWorkflow - instance methods with "use step" directive | wrun_01KV5XRPK2D261ZS31FAFTJQFR
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context | wrun_01KV5XS3V1J5M5BWV684JVE0FD
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument | wrun_01KV5XSD3V036Y6TWSSB0C2HJ5
  • cancelRun - cancelling a running workflow | wrun_01KV5XSN8VDAFA49VYG1QXJYX6
  • cancelRun via CLI - cancelling a running workflow | wrun_01KV5XSYS57PSNVNCXSEDFK89J
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router
  • hookWithSleepWorkflow - hook payloads delivered correctly with concurrent sleep | wrun_01KV5XTBFB5CPTJY2JRKEDSSE4
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration | wrun_01KV5XTWGWT2FGB5ZF0E104VHN
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control) | wrun_01KV5XV8GB7CDABGYTC0AVXFFN
  • importMetaUrlWorkflow - import.meta.url is available in step bundles | wrun_01KV5XVFJ6V9VAZ7E05BX2S1Z1
  • metadataFromHelperWorkflow - getWorkflowMetadata/getStepMetadata work from module-level helper (#1577) | wrun_01KV5XVHWFXCHDEWHG9WKH5ZP9
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KV5XVM7D05NYPTH0W242GS66

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 94 0 7
✅ example 94 0 7
✅ express 94 0 7
✅ fastify 94 0 7
✅ hono 94 0 7
✅ nextjs-turbopack 99 0 2
✅ nextjs-webpack 99 0 2
✅ nitro 94 0 7
✅ nuxt 94 0 7
✅ sveltekit 94 0 7
✅ vite 94 0 7
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 95 0 6
✅ express-stable 95 0 6
✅ fastify-stable 95 0 6
✅ hono-stable 95 0 6
✅ nextjs-turbopack-canary 82 0 19
✅ nextjs-turbopack-stable 101 0 0
✅ nextjs-webpack-canary 82 0 19
✅ nextjs-webpack-stable 101 0 0
✅ nitro-stable 95 0 6
✅ nuxt-stable 95 0 6
✅ sveltekit-stable 95 0 6
✅ vite-stable 95 0 6
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 95 0 6
✅ express-stable 95 0 6
✅ fastify-stable 95 0 6
✅ hono-stable 95 0 6
✅ nextjs-turbopack-canary 82 0 19
✅ nextjs-turbopack-stable 101 0 0
✅ nextjs-webpack-canary 82 0 19
✅ nextjs-webpack-stable 101 0 0
✅ nitro-stable 95 0 6
✅ nuxt-stable 95 0 6
✅ sveltekit-stable 95 0 6
✅ vite-stable 95 0 6
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 94 0 7
✅ express-stable 94 0 7
✅ fastify-stable 94 0 7
✅ hono-stable 94 0 7
✅ nextjs-turbopack-canary 81 0 20
✅ nextjs-turbopack-stable 100 0 1
✅ nextjs-webpack-canary 81 0 20
✅ nextjs-webpack-stable 100 0 1
✅ nitro-stable 94 0 7
✅ nuxt-stable 94 0 7
✅ sveltekit-stable 94 0 7
✅ vite-stable 94 0 7
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 101 0 0
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 3 0 2
✅ redis-dev 3 0 2
❌ redis 64 18 0
✅ turso-dev 3 0 2
❌ turso 3 79 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 95 0 6
✅ e2e-local-dev-tanstack-start-stable 95 0 6
✅ e2e-local-postgres-nest-stable 94 0 7
✅ e2e-local-postgres-tanstack-start-stable 94 0 7
✅ e2e-local-prod-nest-stable 95 0 6
✅ e2e-local-prod-tanstack-start-stable 95 0 6

📋 View full workflow run

@vercel vercel Bot temporarily deployed to Preview – workflow-docs June 12, 2026 16:38 Inactive

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

need to fix version numbers

Comment thread .changeset/byte-stream-wire-framing.md Outdated
Signed-off-by: Peter Wielander <mittgfu@gmail.com>
@VaguelySerious VaguelySerious merged commit f2ad726 into stable Jun 15, 2026
76 of 94 checks passed
@VaguelySerious VaguelySerious deleted the backport/pr-1853-to-stable branch June 15, 2026 15:07
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.

1 participant