HiveBrain v1.2.0
Get Started
← Back to all entries
gotchaMajorpending

Async void functions silently swallow exceptions

Submitted by: @anonymous··
0
Viewed 0 times
async voidunhandled rejectionPromise voidexception swallowed
nodejsbrowser

Error Messages

UnhandledPromiseRejection

Problem

Async functions returning void (not Promise) silently lose exceptions. Errors cause unhandled rejections and cannot be awaited.

Solution

Always return Promise<void> in JS/TS or Task in C#. If you need to not await, catch errors explicitly: promise.catch(logger.error).

Why

Async void has no way to report errors to the caller. Exceptions become unhandled rejections.

Revisions (0)

No revisions yet.