diff --git a/cmd/tsconnect/wasm/wasm_js.go b/cmd/tsconnect/wasm/wasm_js.go index 67208be18..4d6a7c057 100644 --- a/cmd/tsconnect/wasm/wasm_js.go +++ b/cmd/tsconnect/wasm/wasm_js.go @@ -625,6 +625,11 @@ func (i *jsIPN) logout() { }() } +// shutdown tears down the backend and lets main return, which exits the whole +// Go runtime. Callers should await the runtime's exit rather than the promise +// returned here: closing shutdownCh races with makePromise resolving, so the +// promise may never settle. There is exactly one IPN per runtime, so the once +// and the channel belong to the same instance and a second call is a no-op. func (i *jsIPN) shutdown() js.Value { return makePromise(func() (any, error) { i.shutdownOnce.Do(func() {