Skip to content

Commit 66f7f37

Browse files
authored
[Web] Handle LocalSession init in WASM RPC server (#18687)
## Why When a client connects without session_constructor_args, the RPC protocol sends nargs=0 (LocalSession request). The WASM RPC server requires ["rpc.WasmSession", wasm_binary] instead. ## How Adds handling to skip LocalSession init packets and wait for the proper WasmSession init, with a log message for debugging.
1 parent 87f478e commit 66f7f37

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

web/src/rpc_server.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ export class RPCServer {
228228
// eslint-disable-next-line @typescript-eslint/no-unused-vars
229229
const ver = Uint8ArrayToString(reader.readByteArray());
230230
const nargs = reader.readU32();
231+
232+
// nargs=0 means no session_constructor_args (LocalSession request).
233+
// WASM RPC requires ["rpc.WasmSession", wasm_binary]. Wait for proper init.
234+
if (nargs === 0) {
235+
this.log("Received LocalSession init (nargs=0), waiting for WasmSession init...");
236+
this.requestBytes(SizeOf.I64);
237+
this.state = RPCServerState.ReceivePacketHeader;
238+
return;
239+
}
240+
231241
const args = [];
232242
for (let i = 0; i < nargs; ++i) {
233243
const typeIndex = reader.readU32();

0 commit comments

Comments
 (0)