Sending binary via a typescript websocket client call fails
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 212
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 119
Description
Golem Version 1.5.1
import { agent, BaseAgent } from "@golemcloud/golem-ts-sdk";
@agent()
class WebSocketTest extends BaseAgent {
constructor(name: string) {
super();
}
async binary(url: string): Promise<string> {
return new Promise((resolve, reject) => {
const ws = new WebSocket(url);
ws.onopen = () => {
const buffer = new ArrayBuffer(10);
const view = new Uint8Array(buffer);
for (let i = 0; i < view.length; i++) {
view[i] = 255;
}
ws.send(buffer);
}
ws.onmessage = (event) => { ws.close();
console.log(event);
resolve("Done");
};
ws.onerror = (event) => reject(new Error(event.message));
});
}
}
golem agent invoke 'WebSocketTest("t1")' 'binary' '"ws://localhost:9090"'
Results in
JavaScript error: Error converting from js 'object' into type 'array'
[2026-05-12T14:02:18.004Z] [INVOKE ] STARTED binary (6758a2af-0d62-40fd-8bad-63937f9cbc54)
{"context":"","level":"STDERR","message":"","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":"thread '<unnamed>' (1) panicked at src/internal.rs:188441:","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":"Exception during awaiting call result for guest.invoke:","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":"JavaScript error: Error converting from js 'object' into type 'array'","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":"Stack:","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at <anonymous> (user:125:48)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at call (native)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at _dispatch (__wasm_rquickjs_builtin/websocket:365:32)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at send (__wasm_rquickjs_builtin/websocket:293:72)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at <anonymous> (user:118:25)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at call (native)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at _dispatch (__wasm_rquickjs_builtin/websocket:365:32)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at <anonymous> (__wasm_rquickjs_builtin/websocket:154:22)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at apply (native)","timestamp":"2026-05-12T14:02:18.010Z"}
{"context":"","level":"STDERR","message":" at call (native)","timestamp":"2026-05-12T14:02:18.010Z"}
error: Agent Service - Error: 500 Internal Server Error, Invocation Failed
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the WebSocket send path shown in the stack trace, particularly __wasm_rquickjs_builtin/websocket and its _dispatch/send entries. Reproduce the provided ArrayBuffer example against the local WebSocket endpoint, then verify that sending binary data no longer fails with the JavaScript object-to-array conversion error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, wasm
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100