refactor: centralize dashboard url + ws close code

This commit is contained in:
Peter Steinberger
2026-01-14 23:42:12 +00:00
parent 983e1b2303
commit 50fa106d87
3 changed files with 42 additions and 30 deletions

View File

@@ -50,6 +50,9 @@ export type GatewayBrowserClientOptions = {
onGap?: (info: { expected: number; received: number }) => void;
};
// 4008 = application-defined code (browser rejects 1008 "Policy Violation")
const CONNECT_FAILED_CLOSE_CODE = 4008;
export class GatewayBrowserClient {
private ws: WebSocket | null = null;
private pending = new Map<string, Pending>();
@@ -134,8 +137,7 @@ export class GatewayBrowserClient {
this.opts.onHello?.(hello);
})
.catch(() => {
// 4008 = application-defined code (browser rejects 1008 "Policy Violation")
this.ws?.close(4008, "connect failed");
this.ws?.close(CONNECT_FAILED_CLOSE_CODE, "connect failed");
});
}