Skip to content

Backport #2152: [world-local] Reduce sequential replay I/O - #2707

Merged
VaguelySerious merged 1 commit into
stablefrom
backport/pr-2152-to-stable
Aug 25, 2026
Merged

Backport #2152: [world-local] Reduce sequential replay I/O#2707
VaguelySerious merged 1 commit into
stablefrom
backport/pr-2152-to-stable

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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

AI recommendation: This is a self-contained @workflow/world-local performance optimization plus correctness bug fixes (relative-dataDir cache misses, cached-object aliasing, external-directory cleanup recovery) with focused regression tests, marked as a patch. All changed files are in packages/world-local/, which is actively maintained on stable (verified the files exist there and several match the commit's merge-base blobs), so the changes apply to functionality already present on stable.


Conflict resolution (taken over manually)

The original AI conflict resolution had gone stale — stable moved ~85 commits past the branch point. I rebased onto current stable (853a316c7) and resolved the conflicts by hand. The branch is now a single signed commit parented directly on stable HEAD.

Two conflicts, both between disjoint additions:

File Conflict Resolution
src/index.ts stable replaced mergedConfig.recoverActiveRuns ?? true with resolveRecoverActiveRuns(mergedConfig) (#2914) on the line adjacent to the new createStorage destructuring Kept both: destructure clearCache off createStorage, keep resolveRecoverActiveRuns
src/fs.test.ts stable added a deleteJSON describe block and import (#3215 Windows EPERM retry) where the patch adds an ensureDir block and its imports Kept both blocks and both imports

I also dropped one gratuitous change the AI resolution had carried over from main: it pluralized the // Per-instance in-process mutex comment above hookLocks. main has several lock maps there; stable has only hookLocks, so the singular was correct and the change was both unrelated to this patch and inaccurate here. The diff against stable is now exactly the upstream #2152 change, nothing more.

Semantic-conflict review

Clean textual merges can still be wrong, so I checked the stable-only world-local changes that land near the new event cache. The cache is read-through over append-only event files, so the risk is any path that deletes or overwrites an event file:

  • Backport #2986: Implement max_events per run limit #3042 (max_events) — only reports a per-run ceiling on responses; never prunes events. No interaction.
  • Scope correlation-ID event lookups to a run #3762 (scope correlation-ID lookups to a run) — merged into the same listByCorrelationId call the patch adds cachedItems to. The runId filter is preserved and is orthogonal to the cache (which is keyed by path, with the filter still applied downstream).
  • fix(world-local): rebuild hook caches from event log #2747 (rebuild hook caches from event log) and repairHookEntityFromPersistedEvent — read events straight from disk without the cache. That's a cache miss, not staleness; disk stays authoritative.
  • legacy.ts writes wait_completed / hook_received via writeJSON, bypassing storeEvent. Also a miss, not staleness — and identical to main's behavior.
  • clear() in index.ts is the one path that deletes event files; the patch already guards it with clearStorageCache().

I confirmed the cache-key alignment the patch depends on still holds on stable: taggedPathresolveWithinBasepath.resolve, and paginatedFileSystemQuery now resolves its directory too, so writer and reader agree on absolute keys even when dataDir is relative.

Verification

  • pnpm typecheck — 40/40 tasks pass.
  • @workflow/world-local — 448/448 tests pass, including the patch's new cases (ensureDir mkdir-dedup + both external-cleanup recovery tests, the four event-cache tests, the tagged-clear() test) running alongside stable's own (deleteJSON EPERM retry, rebuilds missing hook caches from a committed hook_created event).
  • @workflow/world-testing — 6/6 pass (conformance suite against the local world).
  • biome check on the changed files reports the same 9 pre-existing warnings as stable's versions of those files. No new findings.

@workflow/core fails 7 DOMException serialization tests on my machine, on Node v22.18.0. That is environmental and pre-existing: this branch does not touch packages/core (see the diffstat — every changed file is under packages/world-local/ plus the changeset).

Changeset

patch on @workflow/world-local, unchanged. stable is in regular (non-pre) mode, so this publishes as a latest patch.

CI on the rebased commit

Green on everything that gates: E2E Required Check, Unit Tests on ubuntu + windows, E2E Windows Tests, and every E2E Local Dev / Local Postgres / Local Prod / Vercel Prod lane across all frameworks.

Four red, none of them gating and none related to this change (it touches only packages/world-local/):

  • E2E Community World (Redis) / (Turso) — FAILURE; (MongoDB) — CANCELLED. These are excluded from e2e-required-check by design; the job's own comment says so ("The job is non-blocking via its exclusion from e2e-required-check, so this surfaces failures without gating merges"). Redis fails in dev.test.ts, a known-flaky discovery suite.
  • Vercel – workbench-python-workflow — a workbench deploy unrelated to world-local.

stable has since advanced to 699e01ed1 (#2889, namespaced active-run recovery). This branch does not conflict with it, and stable's ruleset sets strict_required_status_checks_policy: false, so no rebase is needed. I checked the overlap anyway: #2889 gives reenqueueActiveRuns an optional fourth namespace parameter, so the three-argument call in world-local/src/index.ts — the file I resolved a conflict in — is unaffected, and its other world-local edit is confined to reenqueue.test.ts, which this branch does not touch.

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1afdfdb

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

This PR includes changesets to release 18 packages
Name Type
@workflow/world-local Patch
@workflow/cli Patch
@workflow/core Patch
@workflow/vitest Patch
@workflow/world-postgres Patch
workflow Patch
@workflow/world-testing Patch
@workflow/builders Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/web-shared Patch
@workflow/web 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 Jun 30, 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 30, 2026 5:54am
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jun 30, 2026 5:54am
example-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-astro-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-express-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-fastify-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-hono-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-nitro-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-nuxt-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-sveltekit-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workbench-vite-workflow Ready Ready Preview, Comment Jun 30, 2026 5:54am
workflow-docs Ready Ready Preview, Comment, Open in v0 Jun 30, 2026 5:54am
workflow-swc-playground Ready Ready Preview, Comment Jun 30, 2026 5:54am
workflow-tarballs Ready Ready Preview, Comment Jun 30, 2026 5:54am
workflow-web Ready Ready Preview, Comment Jun 30, 2026 5:54am

@pranaygp

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

* [world-local] Reduce sequential replay I/O

* Fix relative local event cache lookups

* Keep event cache eviction test lightweight

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
@pranaygp
pranaygp force-pushed the backport/pr-2152-to-stable branch from ae91f7c to 1afdfdb Compare August 24, 2026 22:52
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1099 0 78 1177
✅ 💻 Local Development 1198 0 86 1284
✅ 📦 Local Production 1198 0 86 1284
✅ 🐘 Local Postgres 1198 0 86 1284
✅ 🪟 Windows 107 0 0 107
❌ 🌍 Community Worlds 82 106 9 197
✅ 📋 Other 606 0 36 642
Total 5488 106 381 5975

❌ Failed Tests

🌍 Community Worlds (106 failed)

redis (21 failed):

  • hookWorkflow | wrun_01M0TZQKMM0SVVEZFYDBVJ50X0
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01M0TZQTQJYBR4VG5H5106XKEP
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01M0TZR4FTNPQYFPE96TC26CY2
  • sleepingWorkflow | wrun_01M0TZS4HZ882KQRMP7XWJQ4G5
  • 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
  • error handling serialization failures step-argument serialization failure is catchable in workflow code
  • error handling serialization failures uncaught step-argument serialization failure fails the run as USER_ERROR without redelivery retries
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01M0V012TZ53CNRDA21EY33W71
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01M0V01EK1P0HSAQGKEG2DVBNN
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01M0V01NMKVMWG7N3B1KEQHX0N
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01M0V023BGKGDMES1742SKY95N
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01M0V02YGVY38ARDFDVQYDX3Z3
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01M0V031WX8H5J61ZJBRZF21YM
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01M0V0371GG6A94VPQ9TMZQBQD
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01M0V03C4PBTBTASYWD50V0D2R
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01M0V03MX63VMJGJYKB4E3DX1H
  • pages router sleepingWorkflow via pages router
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01M0V08ZYHMTESRMFX8C6F07B5

turso (85 failed):

  • addTenWorkflow | wrun_01M0TZPNFB7H2VNMH2C1NCBWT2
  • addTenWorkflow | wrun_01M0TZPNFB7H2VNMH2C1NCBWT2
  • deploymentId: 'latest' is a no-op in non-Vercel worlds
  • wellKnownAgentWorkflow (.well-known/agent) | wrun_01M0TZRE2GMG75YMBRJHZMCQ51
  • should work with react rendering in step
  • promiseAllWorkflow | wrun_01M0TZPWA65FXP478GA721RNT6
  • promiseRaceWorkflow | wrun_01M0TZQ1VAYJQW8TC57MART88N
  • promiseAnyWorkflow | wrun_01M0TZQ47WZS5GCQBPQFD708SF
  • importedStepOnlyWorkflow | wrun_01M0TZRVD68WFVX4SFP14DBD9E
  • readableStreamWorkflow | wrun_01M0TZQ6MNQCB18HNCWY45554T
  • hookWorkflow | wrun_01M0TZQKMM0SVVEZFYDBVJ50X0
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01M0TZQTQJYBR4VG5H5106XKEP
  • webhookWorkflow | wrun_01M0TZQYZ4X4NSCDA6PC4H0KZS
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01M0TZR4FTNPQYFPE96TC26CY2
  • sleepingWorkflow | wrun_01M0TZS4HZ882KQRMP7XWJQ4G5
  • parallelSleepWorkflow | wrun_01M0TZSMK3KP5X20JE8DQP3H70
  • sleepWinsRaceWorkflow | wrun_01M0TZSR3K9A77PWFM71TEA2JA
  • stepWinsRaceWorkflow | wrun_01M0TZSVEVM2BAJPKZYVR7BE3C
  • nullByteWorkflow | wrun_01M0TZSYTATAHHQP57SMQD0CVK
  • workflowAndStepMetadataWorkflow | wrun_01M0TZT10CVN4GJMT155WVAF94
  • 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_01M0TZWA70JZEWDR6J17QHJB0G
  • writableForwardedFromWorkflowWorkflow | wrun_01M0TZWPD3HHH7FT2NZ60Z9K75
  • writableForwardedFromStepWorkflow | wrun_01M0TZWSMCH5P6VRWEKA7BQ90D
  • fetchWorkflow | wrun_01M0TZWWBWMS536P4SNWTRXBAW
  • promiseRaceStressTestWorkflow | wrun_01M0TZWZRPQXKXPX8GBAT2HY70
  • 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 serialization failures step-argument serialization failure is catchable in workflow code
  • error handling serialization failures uncaught step-argument serialization failure fails the run as USER_ERROR without redelivery retries
  • 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_01M0V00QHA3CH9BTYHWSEN1F5C
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01M0V012TZ53CNRDA21EY33W71
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01M0V01EK1P0HSAQGKEG2DVBNN
  • 'hookGetConflictWithPriorStepWorkflow' - hook.getConflict() does not block step execution | wrun_01M0V01GVGN3K930B6EQJ7B385
  • 'hookGetConflictWithParallelStepWorkfl…' - hook.getConflict() does not block step execution | wrun_01M0V01KANE4N0EFRT64T8J4PZ
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01M0V01NMKVMWG7N3B1KEQHX0N
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01M0V023BGKGDMES1742SKY95N
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01M0V02YGVY38ARDFDVQYDX3Z3
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01M0V031WX8H5J61ZJBRZF21YM
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01M0V0371GG6A94VPQ9TMZQBQD
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01M0V03C4PBTBTASYWD50V0D2R
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01M0V03MX63VMJGJYKB4E3DX1H
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running | wrun_01M0V03VTA8E28F9WKP4EGHJVV
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars) | wrun_01M0V04AQXAVRH1GK0XTKNRSRX
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument | wrun_01M0V04KWJ0SBJG75PQ5EVKBBJ
  • closureVariableWorkflow - nested step functions with closure variables | wrun_01M0V04S3F8SR2B184GNRM5ZHK
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step | wrun_01M0V04V8K6EWM24MRPPN6MMAA
  • 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_01M0V05A2WY1PS0YX6D5AZA760
  • Calculator.calculate - static workflow method using static step methods from another class | wrun_01M0V05FQWV45P4PD78FZJ7W06
  • AllInOneService.processNumber - static workflow method using sibling static step methods | wrun_01M0V05P9ANY342DX1216TJ6KS
  • ChainableService.processWithThis - static step methods using this to reference the class | wrun_01M0V05VWRWZ4WQ53B41K462H4
  • thisSerializationWorkflow - step function invoked with .call() and .apply() | wrun_01M0V061GHH2YDD80GR7Z5BVFA
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE | wrun_01M0V068AGS7466PE14WDDAM0H
  • instanceMethodStepWorkflow - instance methods with "use step" directive | wrun_01M0V06ETEHN06AYEMPRN50S3B
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context | wrun_01M0V06V9Z46V4X9YBXW25MEGW
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument | wrun_01M0V073236H088XW6ZR24332D
  • cancelRun - cancelling a running workflow | wrun_01M0V079Q2YFJ2E9REH63BJXDN
  • cancelRun via CLI - cancelling a running workflow | wrun_01M0V07E9BA86SBAQE32P10M3B
  • 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_01M0V07NP6WE8T7VHAB0PQ1GY1
  • hookWithSleepFinalStepWorkflow - step only on final payload | wrun_01M0V0823016F1CWJAHG94DMRT
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration | wrun_01M0V08AD7KJNVJVJJ0BWX7HDS
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control) | wrun_01M0V08MSXZXFW5VX6T827V7B7
  • importMetaUrlWorkflow - import.meta.url is available in step bundles | wrun_01M0V08VE5MBN0PTG9X95EAR7A
  • metadataFromHelperWorkflow - getWorkflowMetadata/getStepMetadata work from module-level helper (#1577) | wrun_01M0V08XRFWZNW328RNDXCTJT0
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01M0V08ZYHMTESRMFX8C6F07B5

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 99 0 8
✅ example 99 0 8
✅ express 99 0 8
✅ fastify 99 0 8
✅ hono 99 0 8
✅ nextjs-turbopack 104 0 3
✅ nextjs-webpack 104 0 3
✅ nitro 99 0 8
✅ nuxt 99 0 8
✅ sveltekit 99 0 8
✅ vite 99 0 8
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 101 0 6
✅ express-stable 101 0 6
✅ fastify-stable 101 0 6
✅ hono-stable 101 0 6
✅ nextjs-turbopack-canary 88 0 19
✅ nextjs-turbopack-stable 107 0 0
✅ nextjs-webpack-canary 88 0 19
✅ nextjs-webpack-stable 107 0 0
✅ nitro-stable 101 0 6
✅ nuxt-stable 101 0 6
✅ sveltekit-stable 101 0 6
✅ vite-stable 101 0 6
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 101 0 6
✅ express-stable 101 0 6
✅ fastify-stable 101 0 6
✅ hono-stable 101 0 6
✅ nextjs-turbopack-canary 88 0 19
✅ nextjs-turbopack-stable 107 0 0
✅ nextjs-webpack-canary 88 0 19
✅ nextjs-webpack-stable 107 0 0
✅ nitro-stable 101 0 6
✅ nuxt-stable 101 0 6
✅ sveltekit-stable 101 0 6
✅ vite-stable 101 0 6
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 101 0 6
✅ express-stable 101 0 6
✅ fastify-stable 101 0 6
✅ hono-stable 101 0 6
✅ nextjs-turbopack-canary 88 0 19
✅ nextjs-turbopack-stable 107 0 0
✅ nextjs-webpack-canary 88 0 19
✅ nextjs-webpack-stable 107 0 0
✅ nitro-stable 101 0 6
✅ nuxt-stable 101 0 6
✅ sveltekit-stable 101 0 6
✅ vite-stable 101 0 6
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 107 0 0
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 4 0 3
✅ redis-dev 4 0 3
❌ redis 67 21 0
✅ turso-dev 4 0 3
❌ turso 3 85 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 101 0 6
✅ e2e-local-dev-tanstack-start-stable 101 0 6
✅ e2e-local-postgres-nest-stable 101 0 6
✅ e2e-local-postgres-tanstack-start-stable 101 0 6
✅ e2e-local-prod-nest-stable 101 0 6
✅ e2e-local-prod-tanstack-start-stable 101 0 6

📋 View full workflow run

@VaguelySerious
VaguelySerious merged commit 0fd781a into stable Aug 25, 2026
94 of 98 checks passed
@VaguelySerious
VaguelySerious deleted the backport/pr-2152-to-stable branch August 25, 2026 14:35
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.

2 participants