Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions engine/sdks/typescript/runner/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ export class Runner {
msg: "error during websocket shutdown:",
error,
});
pegboardWebSocket.close();
pegboardWebSocket.close(1011, "pegboard.shutdown_error");
}
}
} else {
Expand Down Expand Up @@ -733,7 +733,7 @@ export class Runner {
this.log?.error(
"found duplicate pegboardWebSocket, closing previous",
);
this.#pegboardWebSocket.close(1000, "duplicate_websocket");
this.#pegboardWebSocket.close(1000, "pegboard.duplicate_websocket");
}

const ws = new WS(this.pegboardUrl, protocols) as any as WebSocket;
Expand Down
4 changes: 3 additions & 1 deletion engine/sdks/typescript/runner/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export function parseWebSocketCloseReason(
const [group, error] = mainPart.split(".");

if (!group || !error) {
logger()?.warn({ msg: "failed to parse close reason", reason });
if (reason) {
logger()?.warn({ msg: "failed to parse close reason", reason });
}
return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ public actor ActorConnection {
} else {
errorToThrow = ActorError(group: group, code: code, message: "Connection closed: \(reason)", metadata: nil)
}
} else {
} else if !reason.isEmpty {
logger.warning("failed to parse close reason reason=\(reason, privacy: .public)")
}
}
Expand Down
4 changes: 3 additions & 1 deletion rivetkit-typescript/packages/rivetkit/src/client/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export function parseWebSocketCloseReason(
const [group, code] = mainPart.split(".");

if (!group || !code) {
logger().warn({ msg: "failed to parse close reason", reason });
if (reason) {
logger().warn({ msg: "failed to parse close reason", reason });
}
return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export async function createWebSocketProxy(

if (state.targetWs) {
if (state.targetWs.readyState === WebSocket.OPEN) {
state.targetWs.close(1011, "Client WebSocket error");
state.targetWs.close(1011, "ws.client_error");
} else if (state.targetWs.readyState === WebSocket.CONNECTING) {
state.targetWs.close();
state.targetWs.close(1011, "ws.client_error");
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions rivetkit-typescript/packages/rivetkit/src/sandbox/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,12 @@ class DirectTerminalSession implements TerminalSession {
this.closeSignalSent = true;
this.sendFrame({ type: "close" });
}
this.socket.close();
this.socket.close(1000, "sandbox.client_closed");
return;
}

if (this.socket.readyState !== 3) {
this.socket.close();
this.socket.close(1000, "sandbox.client_closed");
}
}

Expand Down
Loading