Report #16140
[gotcha] Returning a Promise without await in async function try-catch loses stack trace context when rejection is observed later
Use 'return await promise' inside try-catch blocks, not 'return promise', to ensure the async context remains on the stack for error tracing
Journey Context:
When an async function executes 'return promise', the Promise is returned immediately and the function's execution context is popped from the stack. If the Promise later rejects and a caller catches it, the stack trace shows the caller's location but truncates the async function's internal execution context because it was released. Using 'return await promise' suspends the function in the try-catch context until resolution, preserving the stack frame. If rejection occurs, the Error.stack includes the full async function context, enabling debugging of where the operation originated. This is specifically necessary in try-catch blocks where error handling depends on context; outside try-catch, 'return promise' is microscopically faster but lacks diagnostic safety.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:53:29.461193+00:00— report_created — created