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) <noreply@anthropic.com>
This commit is contained in:
Tomek Zawadzki
2026-08-25 17:26:43 +02:00
parent dfa98d5946
commit 5fa9e3cc1c
+3 -2
View File
@@ -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<T>(
fn: () => Promise<T>,