This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 66f7f378d5 [Web] Handle LocalSession init in WASM RPC server (#18687)
66f7f378d5 is described below

commit 66f7f378d57a3814137b9d1177ea3609bf271dc7
Author: Guan-Ming (Wesley) Chiu <[email protected]>
AuthorDate: Tue Jan 27 21:37:50 2026 +0800

    [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.
---
 web/src/rpc_server.ts | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/web/src/rpc_server.ts b/web/src/rpc_server.ts
index 1fead65311..c16c01ad57 100644
--- a/web/src/rpc_server.ts
+++ b/web/src/rpc_server.ts
@@ -228,6 +228,16 @@ export class RPCServer {
       // eslint-disable-next-line @typescript-eslint/no-unused-vars
       const ver = Uint8ArrayToString(reader.readByteArray());
       const nargs = reader.readU32();
+
+      // nargs=0 means no session_constructor_args (LocalSession request).
+      // WASM RPC requires ["rpc.WasmSession", wasm_binary]. Wait for proper 
init.
+      if (nargs === 0) {
+        this.log("Received LocalSession init (nargs=0), waiting for 
WasmSession init...");
+        this.requestBytes(SizeOf.I64);
+        this.state = RPCServerState.ReceivePacketHeader;
+        return;
+      }
+
       const args = [];
       for (let i = 0; i < nargs; ++i) {
         const typeIndex = reader.readU32();

Reply via email to