diff --git a/src/mono/wasm/runtime/marshal-to-cs.ts b/src/mono/wasm/runtime/marshal-to-cs.ts index 66f10166f35b1d..a0f5b58a5cd332 100644 --- a/src/mono/wasm/runtime/marshal-to-cs.ts +++ b/src/mono/wasm/runtime/marshal-to-cs.ts @@ -347,7 +347,9 @@ function _marshal_task_to_cs(arg: JSMarshalerArgument, value: Promise, _?: teardown_managed_proxy(holder, gc_handle); // this holds holder alive for finalizer, until the promise is freed } catch (ex) { - mono_log_warn("Exception marshalling error of JS promise to CS: ", ex); + if (!loaderHelpers.is_exited()) { + mono_log_warn("Exception marshalling error of JS promise to CS: ", ex); + } } }); } diff --git a/src/mono/wasm/runtime/web-socket.ts b/src/mono/wasm/runtime/web-socket.ts index b5de8be473a9af..7d25310d4f9513 100644 --- a/src/mono/wasm/runtime/web-socket.ts +++ b/src/mono/wasm/runtime/web-socket.ts @@ -102,6 +102,13 @@ export function ws_wasm_create(uri: string, sub_protocols: string[] | null, rece ws.addEventListener("open", local_on_open, { once: true }); ws.addEventListener("close", local_on_close, { once: true }); ws.addEventListener("error", local_on_error, { once: true }); + ws.dispose = () => { + ws.removeEventListener("message", local_on_message); + ws.removeEventListener("open", local_on_open); + ws.removeEventListener("close", local_on_close); + ws.removeEventListener("error", local_on_error); + ws_wasm_abort(ws); + }; return ws; } @@ -396,6 +403,7 @@ type WebSocketExtension = WebSocket & { [wasm_ws_pending_send_buffer_offset]: number [wasm_ws_pending_send_buffer_type]: number [wasm_ws_pending_send_buffer]: Uint8Array | null + dispose(): void } type ReceivePromiseControl = PromiseController & {