Skip to content

Conversation

@vercel
Copy link
Contributor

@vercel vercel bot commented Nov 11, 2025

What was implemented

Fixed Windows filesystem support for Vercel Workflow

Issue Description

Users on Windows were experiencing the following error when using workflows:

ReferenceError: Workflow "workflow//C:\\dev\\birthday-card-generator\\app\\api\\generate\\route.ts//handleOrder" must be a function, but got "undefined" instead

The problem was that workflow names contained Windows path separators (backslashes) during lookup, but workflows were registered with normalized paths (forward slashes) during the SWC transform process.

Root Cause

The SWC plugin correctly normalizes file paths from backslashes to forward slashes when generating workflow IDs during bundling. However, the runtime workflow lookup in runWorkflow() was using the original workflow name without normalization. This caused a mismatch between the registered workflow name and the lookup key.

Solution Implemented

Modified the workflow lookup logic in packages/core/src/workflow.ts to normalize Windows path separators before attempting to retrieve workflows from the registry:

Files Modified:

  1. packages/core/src/workflow.ts

    • Added path normalization before workflow lookup: workflowRun.workflowName.replace(/\\/g, '/')
    • Updated error message to use the normalized name for consistency
  2. packages/core/src/parse-name.test.ts

    • Added test case to verify Windows path normalization works correctly
    • Test covers the specific error scenario from the bug report
  3. packages/core/src/workflow.test.ts

    • Added end-to-end test for Windows path handling in workflow execution
    • Test simulates the exact scenario where a workflow is registered with forward slashes but looked up with backslashes

Technical Details

The fix ensures that both the workflow registration (via SWC transform) and workflow lookup (via runtime) consistently use forward slash path separators, eliminating the Windows-specific path mismatch issue.

Testing

  • All existing tests continue to pass
  • New tests specifically validate Windows path handling
  • The fix addresses the exact error scenario reported by the user

This change maintains backward compatibility while fixing Windows filesystem support without affecting Unix/Linux systems.

Code Generation Context

  • Author: allenz
  • Author Name: Allen Zhou

This PR was automatically generated by Vercel Agent

Fixed Windows filesystem support for Vercel Workflow

## Issue Description
Users on Windows were experiencing the following error when using workflows:
```
ReferenceError: Workflow "workflow//C:\\dev\\birthday-card-generator\\app\\api\\generate\\route.ts//handleOrder" must be a function, but got "undefined" instead
```

The problem was that workflow names contained Windows path separators (backslashes) during lookup, but workflows were registered with normalized paths (forward slashes) during the SWC transform process.

## Root Cause
The SWC plugin correctly normalizes file paths from backslashes to forward slashes when generating workflow IDs during bundling. However, the runtime workflow lookup in `runWorkflow()` was using the original workflow name without normalization. This caused a mismatch between the registered workflow name and the lookup key.

## Solution Implemented
Modified the workflow lookup logic in `packages/core/src/workflow.ts` to normalize Windows path separators before attempting to retrieve workflows from the registry:

### Files Modified:

1. **packages/core/src/workflow.ts**
   - Added path normalization before workflow lookup: `workflowRun.workflowName.replace(/\\/g, '/')`
   - Updated error message to use the normalized name for consistency

2. **packages/core/src/parse-name.test.ts**
   - Added test case to verify Windows path normalization works correctly
   - Test covers the specific error scenario from the bug report

3. **packages/core/src/workflow.test.ts**
   - Added end-to-end test for Windows path handling in workflow execution
   - Test simulates the exact scenario where a workflow is registered with forward slashes but looked up with backslashes

## Technical Details
The fix ensures that both the workflow registration (via SWC transform) and workflow lookup (via runtime) consistently use forward slash path separators, eliminating the Windows-specific path mismatch issue.

## Testing
- All existing tests continue to pass
- New tests specifically validate Windows path handling
- The fix addresses the exact error scenario reported by the user

This change maintains backward compatibility while fixing Windows filesystem support without affecting Unix/Linux systems.

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

⚠️ No Changeset found

Latest commit: 6f84d6e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Contributor Author

vercel bot commented Nov 11, 2025

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

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 11, 2025 3:14am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 11, 2025 3:14am
example-workflow Ready Ready Preview Comment Nov 11, 2025 3:14am
workbench-nitro-workflow Ready Ready Preview Comment Nov 11, 2025 3:14am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 11, 2025 3:14am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 11, 2025 3:14am
workbench-vite-workflow Ready Ready Preview Comment Nov 11, 2025 3:14am
workflow-docs Ready Ready Preview Comment Nov 11, 2025 3:14am

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