mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
4d6f797274
* Refactor e2e tests for errors * Improve step error tests to check workflow return value Step error workflows now catch the error and return message/stack, making assertions cleaner. Tests verify both: - Workflow return value (caught error message) - CLI step result (original stack with function names) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add assertion for stack trace in caught step error With the fix in step.ts that propagates original stack traces, we can now verify that caught step errors include function names directly in the workflow return value (not just via CLI). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * logging * Fix: When a step handler is re-invoked after max retries are exhausted, the step_failed event doesn't include a stack trace, breaking stack trace propagation for this edge case. This commit fixes the issue reported at packages/core/src/runtime/step-handler.ts:127-146 ## Stack trace loss in step_failed event when max retries are exceeded **What fails:** Step handler does not include stack property in step_failed event when step is re-invoked after max retries exhausted, causing FatalError in workflow to lose original stack trace **How to reproduce:** 1. Create a step that always fails with an error that includes a stack trace 2. Exhaust all retry attempts (e.g., maxRetries = 3, so 4 total attempts) 3. The step handler is re-invoked (attempt > maxRetries + 1) 4. This triggers the edge case at lines 127-146 in step-handler.ts 5. A step_failed event is created with fatal: true but without stack property 6. When step.ts processes this event (lines 103-104), the stack remains unset since event.eventData.stack is undefined **Result:** FatalError created in workflow has default stack (from step.ts) instead of original error stack from step execution **Expected:** Stack trace should be propagated consistently across all error paths. All other step_failed events with fatal: true include stack property (lines 311-313 and 351-353), but edge case was missing it. **Root cause:** When step handler is re-invoked after max retries exhausted (attempt > maxRetries + 1), the code creates a step_failed event without including step.error?.stack, which contains the previous error information from the last failed attempt. Other code paths capture this correctly. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com> * add withData * Enable source maps for step bundles and validate in e2e tests - Move sourcemap generation from intermediate workflow bundle to steps bundle - Enhance step error tests to validate function names and source files in stack traces - Remove isLocalDeployment() checks since source maps now work in dev mode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add changeset for step bundle source maps 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add changeset for core package e2e test improvements 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Enable source maps in CI e2e tests Add NODE_OPTIONS="--enable-source-maps" to all e2e test jobs to ensure stack traces show original source file paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix step error source map checks for local prod builds Add hasStepSourceMaps() helper that correctly identifies when source maps are expected to work: - Vercel prod: works (production builds have proper source maps) - Local dev: works (DEV_TEST_CONFIG is set, uses step bundle with inline source maps) - Local prod: doesn't work (nitro/bundler output doesn't preserve source maps) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add hasWorkflowSourceMaps() utility for vite-based framework exception - Add isViteBasedFramework() helper to detect vite, sveltekit, astro apps - Add hasWorkflowSourceMaps() to check if workflow errors have source maps (known issue: vite-based frameworks in local deployments don't preserve them) - Refactor e2e.test.ts to use the new utility instead of inline check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * prevent sourcemap checks in nextjs and sveltekit (known offenders) * improve source maps matrix check * fix matrix again * ugh more matrix ignoring --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
31 lines
1009 B
TypeScript
31 lines
1009 B
TypeScript
// ============================================================
|
|
// HELPER FUNCTIONS FOR ERROR TESTING
|
|
// ============================================================
|
|
// These helpers are imported by 99_e2e.ts to test cross-file error propagation.
|
|
// They verify that stack traces correctly reference this file (helpers.ts).
|
|
|
|
// --- Workflow Error Helpers (called directly in workflow code) ---
|
|
|
|
function throwError() {
|
|
throw new Error('Error from imported helper module');
|
|
}
|
|
|
|
/** Called by errorWorkflowCrossFile - creates a call chain across files */
|
|
export function callThrower() {
|
|
throwError();
|
|
}
|
|
|
|
// --- Step Error Helpers (step function that throws from this file) ---
|
|
|
|
function throwErrorFromStep() {
|
|
throw new Error('Step error from imported helper module');
|
|
}
|
|
|
|
/** Step that throws an error - tests cross-file step error stack traces */
|
|
export async function stepThatThrowsFromHelper() {
|
|
'use step';
|
|
throwErrorFromStep();
|
|
return 'never reached';
|
|
}
|
|
stepThatThrowsFromHelper.maxRetries = 0;
|