Cover runtime tolerance for malformed client messages

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-09 23:24:26 +00:00
1 parent bed026aed1
commit 4e36ebaea0
1 file changed
+24
+24
View File
@@ -177,6 +177,30 @@ describe("runtimeApiServer", () => {
client.socket.close();
});
it("ignores malformed client messages and continues processing", async () => {
const server = await startRuntimeApiServer({
port: 0,
launchCwd: process.cwd(),
});
servers.push(server);
const client = await connectClient(server.wsUrl);
await client.nextMessage();
client.socket.send("not-json");
client.socket.send(JSON.stringify({ type: "request", id: "", method: "" }));
const response = await sendRequest(
client.socket,
client.nextMessage,
"todos-after-malformed",
"todos.list",
);
expect(response.ok).toBe(true);
client.socket.close();
});
it("accepts buffer-encoded websocket request payloads", async () => {
const server = await startRuntimeApiServer({
port: 0,