A promise returned from a try block without await escapes its catch and finally
What it finds
``text async function load() { try { return fetchUser(); } catch (e) { return fallback; } } ``
Returning a promise from a try block without await leaves the block before the promise settles. If it rejects, the rejection passes the catch and the finally runs too early: the error handling around it never applies. return await keeps the promise inside the try.
The returned call must certainly give a promise, as a call of an async function or method of this file does, and the try must have a catch or finally in the same async function.
From the rule's source, return_skips_catch.rs.
async function fetchUser(id: string) { return id;}async function load(id: string) { try { return fetchUser(id);tx0 reports: this promise is returned without await } catch (e) { return null; }}async function loadAwaited(id: string) { try { return await fetchUser(id); } catch (e) { return null; }}async function plain(id: string) { return fetchUser(id);} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:return-skips-catch" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:return-skips-catch] reason="..."tx0 explain tx0/ts:return-skips-catch shows the same in the terminal. Found a false positive? Report it.