nickb.dev · Sep 10, 2025
Top-level await is a footgun: The Wasm worker edition
0Sign in to vote or save
This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.
Web workers that load Wasm through an ES6 import with the help of bundler plugins can silently drop messages during startup. This happens because the top level await for Wasm’s asynchronous initialization blocks the worker’s message handler registration, creating a race condition that’s often invisible. 
 As an example, the web worker module below will drop messages until…
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.