From b163860fe4efd53e427cd81bdf35bbc2c09c0ff4 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 21 Apr 2026 00:44:49 -0700 Subject: [PATCH] Guard fibonacciWorkflow against non-finite n (#1814) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- workbench/example/workflows/99_e2e.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/workbench/example/workflows/99_e2e.ts b/workbench/example/workflows/99_e2e.ts index b698e0a292..0904bbf7c0 100644 --- a/workbench/example/workflows/99_e2e.ts +++ b/workbench/example/workflows/99_e2e.ts @@ -1706,6 +1706,9 @@ export async function startFromWorkflow(inputValue: number) { */ export async function fibonacciWorkflow(n: number): Promise { 'use workflow'; + if (!Number.isFinite(n)) { + throw new FatalError(`fibonacciWorkflow requires a finite number for n`); + } if (n <= 1) return n; const [runA, runB] = await Promise.all([