Skip to content

Backport #3372: fix(core): preserve new.target in the deterministic Date override so Date subclasses work - #3434

Merged
TooTallNate merged 1 commit into
stablefrom
backport/pr-3372-to-stable
Aug 10, 2026
Merged

Backport #3372: fix(core): preserve new.target in the deterministic Date override so Date subclasses work#3434
TooTallNate merged 1 commit into
stablefrom
backport/pr-3372-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

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

AI recommendation: This is a correctness fix for a silent data bug: the VM's deterministic Date override dropped new.target, so Date subclasses (e.g. TZDate from @date-fns/tz) lost their identity, methods, and fields inside workflow bodies. The buggy override exists verbatim on stable (packages/core/src/vm/index.ts lines 33-45), the change is a patch scoped to that file plus tests, and determinism is unchanged. The one behavior change — Date() without new now returns the time string per spec instead of a Date object — is a spec-conformance correction that is part of the same fix, not new functionality.

… so `Date` subclasses work (#3372)

* test: add failing test for Date subclassing in workflow VM

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ar_tama <arata.makoto@gmail.com>

* fix(core): preserve `new.target` in the deterministic `Date` override so `Date` subclasses work in workflow functions

The VM's `Date` override was a plain function, so `class X extends Date`
lost the subclass identity: `super()` returned a fresh plain `Date` that
became `this`, dropping the subclass's methods and fields. This silently
broke `Date` subclasses like `TZDate` from `@date-fns/tz`.

Using `class Date extends Date_` keeps `new.target` intact, and `extends`
already wires up the prototype chain and statics, so the manual
`prototype` assignment and `Object.setPrototypeOf` fix-ups are no longer
needed. Determinism is unchanged: zero-arg construction still returns the
fixed timestamp and `Date.now()` is still overridden.

Fixes #3371

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ar_tama <arata.makoto@gmail.com>

* test: add failing test for calling `Date()` without `new`

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ar_tama <arata.makoto@gmail.com>

* fix(core): keep `Date()` callable without `new`

Use a plain function that branches on `new.target` and constructs via
`Reflect.construct(Date_, args, new.target)` instead of a class: subclassing
still works (`new.target` is forwarded), and calling `Date()` without `new`
now matches the spec — arguments are ignored and the (fixed) time string is
returned, where the previous override returned a `Date` object.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ar_tama <arata.makoto@gmail.com>

* chore: update changeset to match the final `Reflect.construct` implementation

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: ar_tama <arata.makoto@gmail.com>

---------

Signed-off-by: ar_tama <arata.makoto@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Makoto Arata <arata.makoto@gmail.com>
@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b001f67

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

This PR includes changesets to release 16 packages
Name Type
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web Patch
workflow Patch
@workflow/world-testing 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 Aug 10, 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 Aug 10, 2026 10:54pm
example-nextjs-workflow-webpack Ready Ready Preview Aug 10, 2026 10:54pm
example-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-astro-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-express-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-fastify-workflow Building Building Preview Aug 10, 2026 10:54pm
workbench-hono-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-nestjs-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-nitro-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-nuxt-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-python-workflow Error Error Aug 10, 2026 10:54pm
workbench-sveltekit-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-tanstack-start-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workbench-vite-workflow Ready Ready Preview Aug 10, 2026 10:54pm
workflow-docs Ready Ready Preview, v0 Aug 10, 2026 10:54pm
workflow-swc-playground Ready Ready Preview Aug 10, 2026 10:54pm
workflow-tarballs Ready Ready Preview Aug 10, 2026 10:54pm
workflow-web Ready Ready Preview Aug 10, 2026 10:54pm

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1077 0 78 1155
✅ 💻 Local Development 1174 0 86 1260
✅ 📦 Local Production 1174 0 86 1260
✅ 🐘 Local Postgres 1174 0 86 1260
✅ 🪟 Windows 105 0 0 105
❌ 🌍 Community Worlds 82 102 9 193
✅ 📋 Other 594 0 36 630
Total 5380 102 381 5863

❌ Failed Tests

🌍 Community Worlds (102 failed)

redis (19 failed):

  • hookWorkflow | wrun_01KZPYMPZYY0G5CKW008GRQHDJ
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KZPYMZ2FQR4M2PG6F1HDPRD1
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KZPYN8VQ2TQ4AEFXQWQVCHZE
  • sleepingWorkflow | wrun_01KZPYP8W33SBAQDJZ4E7W5R7F
  • 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_01KZPYY43D0YZHWNN529B08VQQ
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KZPYYG9PRP8SRK9HDGTHTBH7
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KZPYYRDH0MRXZNXN7DBBW0H0
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KZPYZ6DPN1KEJJRQX2CV9MVD
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KZPZ00FTHW7S99DE04DZHW75
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KZPZ059TW19S7AN0TB4NRCMB
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KZPZ0ARJ15XN4Q04T652T8V7
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KZPZ0G19NKBY9D1GDCCPSXQA
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KZPZ0S7CQ38NHYPTSDK9M9PT
  • pages router sleepingWorkflow via pages router
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KZPZ69TAEADP1EQZ5HAGZG2B

turso (83 failed):

  • addTenWorkflow | wrun_01KZPYKS7C80467GJC25C47R6S
  • addTenWorkflow | wrun_01KZPYKS7C80467GJC25C47R6S
  • deploymentId: 'latest' is a no-op in non-Vercel worlds
  • wellKnownAgentWorkflow (.well-known/agent) | wrun_01KZPYKY3SXCNC4KRJ6PHNG8EM
  • should work with react rendering in step
  • promiseAllWorkflow | wrun_01KZPYM05BP2ASKXC21TWPD83W
  • promiseRaceWorkflow | wrun_01KZPYM4RHV9MH9RZEVH1MGQ7E
  • promiseAnyWorkflow | wrun_01KZPYM7C8X5QZMJ4CAYDB5P36
  • importedStepOnlyWorkflow | wrun_01KZPYMAV3WH5Y58DC2HNQMTA2
  • readableStreamWorkflow | wrun_01KZPYM9NHX30CE1W3ZJE7HYJZ
  • hookWorkflow | wrun_01KZPYMPZYY0G5CKW008GRQHDJ
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KZPYMZ2FQR4M2PG6F1HDPRD1
  • webhookWorkflow | wrun_01KZPYN410WJC92G6K4V5HZ6EQ
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KZPYN8VQ2TQ4AEFXQWQVCHZE
  • sleepingWorkflow | wrun_01KZPYP8W33SBAQDJZ4E7W5R7F
  • parallelSleepWorkflow | wrun_01KZPYPRJMQGGP12XYVMBGXRFJ
  • sleepWinsRaceWorkflow | wrun_01KZPYPWCN7JDDZ6XC2QYTMRC5
  • stepWinsRaceWorkflow | wrun_01KZPYPZPJ2BY1G4YZ1PD9T0Q2
  • nullByteWorkflow | wrun_01KZPYQ3631T1M38M93W90GXTN
  • workflowAndStepMetadataWorkflow | wrun_01KZPYQ5HY98VNYTR2P6QTENR0
  • 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_01KZPYSFGG5WRCGZHP7KT2D05T
  • writableForwardedFromWorkflowWorkflow | wrun_01KZPYSW9Q151WW9NGDA2DXJJ6
  • writableForwardedFromStepWorkflow | wrun_01KZPYT0BCJQ1AR0HTHM35JFG8
  • fetchWorkflow | wrun_01KZPYT3PQMXESJ93G37KZGYBY
  • promiseRaceStressTestWorkflow | wrun_01KZPYT76M0BFMVM07CSNT4HJH
  • 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_01KZPYXQEBM43J0R4J6HJDP2MM
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KZPYY43D0YZHWNN529B08VQQ
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KZPYYG9PRP8SRK9HDGTHTBH7
  • 'hookGetConflictWithPriorStepWorkflow' - hook.getConflict() does not block step execution | wrun_01KZPYYK2CG2CB50E71D12A95E
  • 'hookGetConflictWithParallelStepWorkfl…' - hook.getConflict() does not block step execution | wrun_01KZPYYNMK30ZXVW40X8NASDK2
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KZPYYRDH0MRXZNXN7DBBW0H0
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KZPYZ6DPN1KEJJRQX2CV9MVD
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KZPZ00FTHW7S99DE04DZHW75
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KZPZ059TW19S7AN0TB4NRCMB
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KZPZ0ARJ15XN4Q04T652T8V7
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KZPZ0G19NKBY9D1GDCCPSXQA
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KZPZ0S7CQ38NHYPTSDK9M9PT
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running | wrun_01KZPZ10CX2TQR60K9H12VQPGN
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars) | wrun_01KZPZ1FY2N7YAQDSZPNMST7VY
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument | wrun_01KZPZ1S73DPVHC5107G183KZE
  • closureVariableWorkflow - nested step functions with closure variables | wrun_01KZPZ1Z1ACEXJC48WJ8DXCKNZ
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step | wrun_01KZPZ2194F1AQ87CSPQDNRC98
  • 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_01KZPZ2HB332MMAPJDCKDF73BT
  • Calculator.calculate - static workflow method using static step methods from another class | wrun_01KZPZ2Q2EGG77K6MK8HYHTQ8A
  • AllInOneService.processNumber - static workflow method using sibling static step methods | wrun_01KZPZ2X34JZ2Y9263EF9HAHB0
  • ChainableService.processWithThis - static step methods using this to reference the class | wrun_01KZPZ32Z1F09492NZSCQ4TD89
  • thisSerializationWorkflow - step function invoked with .call() and .apply() | wrun_01KZPZ38NF50AZ68W91VGBK87Q
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE | wrun_01KZPZ3FHEAE0WQZGGAF0EPCT2
  • instanceMethodStepWorkflow - instance methods with "use step" directive | wrun_01KZPZ3PSV46B1RAAAQQ7QH047
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context | wrun_01KZPZ42PT52HASGXBFYJ4H7WB
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument | wrun_01KZPZ4B3KZ0KHYM10Q5W0QT08
  • cancelRun - cancelling a running workflow | wrun_01KZPZ4HWNZ1M9BK8D0X4RA83D
  • cancelRun via CLI - cancelling a running workflow | wrun_01KZPZ4PW0YP77WPNPE34B91BW
  • 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_01KZPZ4YFMKAZ21BS516MSCYHC
  • hookWithSleepFinalStepWorkflow - step only on final payload | wrun_01KZPZ5A49CPPN5QCT63VB4FPD
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration | wrun_01KZPZ5K4X1SJR8XMVGG93TZZT
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control) | wrun_01KZPZ5XZ94185KD3FE4CB0B3V
  • importMetaUrlWorkflow - import.meta.url is available in step bundles | wrun_01KZPZ64XC7Q55BHG4RJJBPGNK
  • metadataFromHelperWorkflow - getWorkflowMetadata/getStepMetadata work from module-level helper (#1577) | wrun_01KZPZ67K3SX3F62TAFFK8H369
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KZPZ69TAEADP1EQZ5HAGZG2B

Details by Category

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

📋 View full workflow run

@TooTallNate
TooTallNate enabled auto-merge (squash) August 10, 2026 23:03
@TooTallNate
TooTallNate merged commit e822a6a into stable Aug 10, 2026
94 of 98 checks passed
@TooTallNate
TooTallNate deleted the backport/pr-3372-to-stable branch August 10, 2026 23:15
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