@@ -5,7 +5,7 @@ import MonoWasmThreads from "consts:monoWasmThreads";
5
5
6
6
import { prevent_timer_throttling } from "./scheduling" ;
7
7
import { Queue } from "./queue" ;
8
- import { ENVIRONMENT_IS_NODE , ENVIRONMENT_IS_SHELL , createPromiseController , mono_assert } from "./globals" ;
8
+ import { ENVIRONMENT_IS_NODE , ENVIRONMENT_IS_SHELL , createPromiseController , loaderHelpers , mono_assert } from "./globals" ;
9
9
import { setI32 , localHeapViewU8 } from "./memory" ;
10
10
import { VoidPtr } from "./types/emscripten" ;
11
11
import { PromiseController } from "./types/internal" ;
@@ -58,17 +58,20 @@ export function ws_wasm_create(uri: string, sub_protocols: string[] | null, rece
58
58
ws . binaryType = "arraybuffer" ;
59
59
const local_on_open = ( ) => {
60
60
if ( ws [ wasm_ws_is_aborted ] ) return ;
61
+ if ( loaderHelpers . is_exited ( ) ) return ;
61
62
open_promise_control . resolve ( ws ) ;
62
63
prevent_timer_throttling ( ) ;
63
64
} ;
64
65
const local_on_message = ( ev : MessageEvent ) => {
65
66
if ( ws [ wasm_ws_is_aborted ] ) return ;
67
+ if ( loaderHelpers . is_exited ( ) ) return ;
66
68
_mono_wasm_web_socket_on_message ( ws , ev ) ;
67
69
prevent_timer_throttling ( ) ;
68
70
} ;
69
71
const local_on_close = ( ev : CloseEvent ) => {
70
72
ws . removeEventListener ( "message" , local_on_message ) ;
71
73
if ( ws [ wasm_ws_is_aborted ] ) return ;
74
+ if ( loaderHelpers . is_exited ( ) ) return ;
72
75
73
76
onClosed ( ev . code , ev . reason ) ;
74
77
@@ -93,6 +96,7 @@ export function ws_wasm_create(uri: string, sub_protocols: string[] | null, rece
93
96
} ;
94
97
const local_on_error = ( ev : any ) => {
95
98
if ( ws [ wasm_ws_is_aborted ] ) return ;
99
+ if ( loaderHelpers . is_exited ( ) ) return ;
96
100
ws . removeEventListener ( "message" , local_on_message ) ;
97
101
const error = new Error ( ev . message || "WebSocket error" ) ;
98
102
mono_log_warn ( "WebSocket error" , error ) ;
0 commit comments