docs(tsconnect/wasm): record why the shutdown promise cannot be awaited

Closing shutdownCh lets main return and the runtime exit, which races
with makePromise invoking resolve, so the promise shutdown() hands back
may never settle. The JS loader already ignores it and awaits the
runtime's exit instead; say so here so the next reader does not take the
unsettled promise for a bug and rewire the callers.

Also note that the once and the channel now belong to the same instance.
webnet/webnet#206 left the shared-channel race to this branch, and the
one-IPN-per-runtime guard dissolves it.

Co-Authored-By: claude-opus-5 <noreply@anthropic.com>
This commit is contained in:
2026-08-30 01:00:32 +00:00
co-authored by Claude
parent 00d16d6ae2
commit c98a03dfa5
+5
View File
@@ -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 { func (i *jsIPN) shutdown() js.Value {
return makePromise(func() (any, error) { return makePromise(func() (any, error) {
i.shutdownOnce.Do(func() { i.shutdownOnce.Do(func() {