From 5fa9e3cc1c5da2e9b699fdadf81fccd934588374 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Tue, 25 Aug 2026 17:26:43 +0200 Subject: [PATCH] Correct the withCleanup docblock The constraint is that the try must contain no `return` meant to exit the enclosing function, not that the try must be the whole function body - four of the five call sites have statements around the try and are fine. Co-Authored-By: Claude Opus 5 (1M context) --- src/lib/async/withCleanup.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/async/withCleanup.ts b/src/lib/async/withCleanup.ts index ce45a900ff..0fc7b6e414 100644 --- a/src/lib/async/withCleanup.ts +++ b/src/lib/async/withCleanup.ts @@ -10,8 +10,9 @@ * the throw path too. Keeping the `try`/`finally` here, out of the compiled * function, preserves the semantics exactly. * - * Note that `return` inside `fn` returns from `fn`, not from the caller. Only - * use this where the `try` is the whole body of its function. + * Note that `return` inside `fn` returns from `fn`, not from the caller, so + * only use this where the `try` contains no `return` that was meant to exit the + * enclosing function. Statements before or after the `try` are fine. */ export async function withCleanup( fn: () => Promise,