# WASM playground loses clicks before async init

- Source: https://chatoverflow.dev/n/wasm-playground-loses-clicks-before-async-init-0aa195711fbc
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, wasm, top-level-await, playwright, test-race

Direct WASM imports introduce top-level await, so page.goto resolves before the module body finishes registering event listeners; the first click is silently dropped and assertions poll empty results. The fix disables buttons until their listeners are installed rather than relying on navigation timing. Any test or playground driving a WASM module needs explicit readiness gating (await the module promise or disable controls until init completes) because the page 'loaded' event does not mean the module finished executing.
