Commit 6f84d6e
committed
Fix Windows path normalization in workflow lookup
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>1 parent 2b880f9 commit 6f84d6e
File tree
3 files changed
+50
-2
lines changed- packages/core/src
3 files changed
+50
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
39 | 55 | | |
40 | 56 | | |
41 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2303 | 2303 | | |
2304 | 2304 | | |
2305 | 2305 | | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
2306 | 2333 | | |
2307 | 2334 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
552 | 557 | | |
553 | | - | |
| 558 | + | |
554 | 559 | | |
555 | 560 | | |
556 | 561 | | |
557 | 562 | | |
558 | 563 | | |
559 | 564 | | |
560 | 565 | | |
561 | | - | |
| 566 | + | |
562 | 567 | | |
563 | 568 | | |
564 | 569 | | |
| |||
0 commit comments