Aller au contenu

Fire And Forget Task (ARCH3021)

Ce contenu n’est pas encore disponible dans votre langue.

Key typescript.async.floating-promise · Severity warning · Category async

A promise produced as an expression statement and never awaited, assigned, or returned loses its exceptions and runs with undefined ordering. The call’s success or failure is never observed.

async function process(): Promise<void> {
sendAnalytics(event); // floating promise - errors swallowed
await saveOrder(order);
}
async function process(): Promise<void> {
await sendAnalytics(event); // awaited, errors propagate
await saveOrder(order);
}

Await the promise, return it, or handle it explicitly with .catch() if it is intentionally detached.