Skip to content

Commit 74adf2d

Browse files
authored
[Web] Fix RPC argument parsing for new FFI string/bytes types (#18683)
## Why Recent FFI refactoring added new type indices kTVMFFIStr (65) and kTVMFFIBytes (66). The RPC server didn't handle these, causing "cannot support type index 65/66" errors when Python sends string/bytes arguments via RPC. ## How `WriteFFIAny` in C++ writes the `type_index` twice for these types. The fix adds handlers that read and discard the duplicate type_index before reading the actual data.
1 parent 7493164 commit 74adf2d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

web/src/rpc_server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,15 @@ export class RPCServer {
234234
if (typeIndex === TypeIndex.kTVMFFIRawStr) {
235235
const str = Uint8ArrayToString(reader.readByteArray());
236236
args.push(str);
237+
} else if (typeIndex === TypeIndex.kTVMFFIStr) {
238+
reader.readU32(); // skip duplicate type_index
239+
const str = Uint8ArrayToString(reader.readByteArray());
240+
args.push(str);
237241
} else if (typeIndex === TypeIndex.kTVMFFIByteArrayPtr) {
238242
args.push(reader.readByteArray());
243+
} else if (typeIndex === TypeIndex.kTVMFFIBytes) {
244+
reader.readU32(); // skip duplicate type_index
245+
args.push(reader.readByteArray());
239246
} else {
240247
throw new Error("cannot support type index " + typeIndex);
241248
}

0 commit comments

Comments
 (0)