Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser] fix for delayed WS close event on NodeJs #89847

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/mono/wasm/runtime/marshal-to-cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ function _marshal_task_to_cs(arg: JSMarshalerArgument, value: Promise<any>, _?:
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);
}
}
});
}
Expand Down
8 changes: 8 additions & 0 deletions src/mono/wasm/runtime/web-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<void> & {
Expand Down
Loading