@@ -6,7 +6,7 @@ import WasmEnableThreads from "consts:wasmEnableThreads";
66import { prevent_timer_throttling } from "./scheduling" ;
77import { Queue } from "./queue" ;
88import { ENVIRONMENT_IS_NODE , ENVIRONMENT_IS_SHELL , createPromiseController , loaderHelpers , mono_assert } from "./globals" ;
9- import { setI32 , localHeapViewU8 } from "./memory" ;
9+ import { setI32 , localHeapViewU8 , forceThreadMemoryViewRefresh } from "./memory" ;
1010import { VoidPtr } from "./types/emscripten" ;
1111import { PromiseController } from "./types/internal" ;
1212import { mono_log_warn } from "./logging" ;
@@ -69,6 +69,9 @@ export function ws_wasm_create(uri: string, sub_protocols: string[] | null, rece
6969 try {
7070 if ( ws [ wasm_ws_is_aborted ] ) return ;
7171 if ( ! loaderHelpers . is_runtime_running ( ) ) return ;
72+ if ( WasmEnableThreads ) {
73+ forceThreadMemoryViewRefresh ( ) ;
74+ }
7275 open_promise_control . resolve ( ws ) ;
7376 prevent_timer_throttling ( ) ;
7477 } catch ( error : any ) {
@@ -79,6 +82,9 @@ export function ws_wasm_create(uri: string, sub_protocols: string[] | null, rece
7982 try {
8083 if ( ws [ wasm_ws_is_aborted ] ) return ;
8184 if ( ! loaderHelpers . is_runtime_running ( ) ) return ;
85+ if ( WasmEnableThreads ) {
86+ forceThreadMemoryViewRefresh ( ) ;
87+ }
8288 web_socket_on_message ( ws , ev ) ;
8389 prevent_timer_throttling ( ) ;
8490 } catch ( error : any ) {
@@ -90,6 +96,9 @@ export function ws_wasm_create(uri: string, sub_protocols: string[] | null, rece
9096 ws . removeEventListener ( "message" , local_on_message ) ;
9197 if ( ws [ wasm_ws_is_aborted ] ) return ;
9298 if ( ! loaderHelpers . is_runtime_running ( ) ) return ;
99+ if ( WasmEnableThreads ) {
100+ forceThreadMemoryViewRefresh ( ) ;
101+ }
93102
94103 ws [ wasm_ws_close_received ] = true ;
95104 ws [ "close_status" ] = ev . code ;
@@ -119,6 +128,9 @@ export function ws_wasm_create(uri: string, sub_protocols: string[] | null, rece
119128 try {
120129 if ( ws [ wasm_ws_is_aborted ] ) return ;
121130 if ( ! loaderHelpers . is_runtime_running ( ) ) return ;
131+ if ( WasmEnableThreads ) {
132+ forceThreadMemoryViewRefresh ( ) ;
133+ }
122134 ws . removeEventListener ( "message" , local_on_message ) ;
123135 const message = ev . message
124136 ? "WebSocket error: " + ev . message
0 commit comments