Guard fibonacciWorkflow against non-finite numbers#1814
Conversation
Throw a FatalError at the top of fibonacciWorkflow if n is not a finite number. Prevents a runaway recursion if the workflow is ever invoked without its numeric argument — NaN - 1 === NaN, NaN <= 1 === false, so the base case would never fire and every descendant would spawn two more children.
|
🧪 E2E Test Results✅ All tests passed Summary
Details by Category✅ 💻 Local Development
✅ 📦 Local Production
✅ 🐘 Local Postgres
✅ 🪟 Windows
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
📊 Benchmark Results
workflow with no steps💻 Local Development
workflow with 1 step💻 Local Development
workflow with 10 sequential steps💻 Local Development
workflow with 25 sequential steps💻 Local Development
workflow with 50 sequential steps💻 Local Development
Promise.all with 10 concurrent steps💻 Local Development
Promise.all with 25 concurrent steps💻 Local Development
Promise.all with 50 concurrent steps💻 Local Development
Promise.race with 10 concurrent steps💻 Local Development
Promise.race with 25 concurrent steps💻 Local Development
Promise.race with 50 concurrent steps💻 Local Development
workflow with 10 sequential data payload steps (10KB)💻 Local Development
workflow with 25 sequential data payload steps (10KB)💻 Local Development
workflow with 50 sequential data payload steps (10KB)💻 Local Development
workflow with 10 concurrent data payload steps (10KB)💻 Local Development
workflow with 25 concurrent data payload steps (10KB)💻 Local Development
workflow with 50 concurrent data payload steps (10KB)💻 Local Development
Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
stream pipeline with 5 transform steps (1MB)💻 Local Development
10 parallel streams (1MB each)💻 Local Development
fan-out fan-in 10 streams (1MB each)💻 Local Development
SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
❌ Some benchmark jobs failed:
Check the workflow run for details. |
There was a problem hiding this comment.
Pull request overview
Adds a defensive runtime guard to the recursive fibonacciWorkflow workbench example to prevent runaway recursion/fan-out when n is NaN/undefined/Infinity, failing the run immediately with a FatalError.
Changes:
- Add
Number.isFinite(n)validation at the top offibonacciWorkflow. - Throw
FatalErrorwhennis not finite to avoid infinite recursive spawning.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fibonacciWorkflow against non-finite numbers
Summary
Throw a
FatalErrorat the top offibonacciWorkflowifnis not a finite number.The workflow recurses via
start(fibonacciWorkflow, [n - 1])/start(fibonacciWorkflow, [n - 2])with a base case ofif (n <= 1) return n. Ifnis everundefined/NaN, that base case never fires (NaN <= 1 === false), and every descendant does the same — spawning two more children. This is a defensive guard that fails the run immediately instead of amplifying.Change
Only touches
workbench/example/workflows/99_e2e.ts. No changeset needed (workbench files aren't published).