fix: cap realtime websocket payloads · openclaw/openclaw@2e406c0
jesse-merhi
·
2026-04-29
·
via Recent Commits to openclaw:main
File tree
src/gateway/voiceclaw-realtime
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { afterEach, describe, expect, it } from "vitest"; |
2 | 2 | import { type RawData, WebSocket, WebSocketServer } from "ws"; |
3 | 3 | import type { ResolvedGatewayAuth } from "../auth.js"; |
| 4 | +import { MAX_PAYLOAD_BYTES } from "../server-constants.js"; |
4 | 5 | import { attachGatewayUpgradeHandler, createGatewayHttpServer } from "../server-http.js"; |
5 | 6 | import { createPreauthConnectionBudget } from "../server/preauth-connection-budget.js"; |
6 | 7 | import type { GatewayWsClient } from "../server/ws-types.js"; |
7 | 8 | import { withTempConfig } from "../test-temp-config.js"; |
8 | 9 | import { VOICECLAW_REALTIME_PATH } from "./paths.js"; |
| 10 | +import { VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES } from "./upgrade.js"; |
9 | 11 | |
10 | 12 | const previousGeminiApiKey = process.env.GEMINI_API_KEY; |
11 | 13 | const previousTestHandshakeTimeout = process.env.OPENCLAW_TEST_HANDSHAKE_TIMEOUT_MS; |
@@ -24,6 +26,10 @@ afterEach(() => {
|
24 | 26 | }); |
25 | 27 | |
26 | 28 | describe("VoiceClaw realtime gateway upgrade", () => { |
| 29 | +it("keeps the realtime websocket payload cap aligned with gateway clients", () => { |
| 30 | +expect(VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES).toBe(MAX_PAYLOAD_BYTES); |
| 31 | +}); |
| 32 | + |
27 | 33 | it("accepts the realtime path without the generic gateway websocket handler", async () => { |
28 | 34 | delete process.env.GEMINI_API_KEY; |
29 | 35 | await withRealtimeGateway(async ({ port }) => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,12 +4,18 @@ import { WebSocketServer } from "ws";
|
4 | 4 | import type { OpenClawConfig } from "../../config/types.openclaw.js"; |
5 | 5 | import type { AuthRateLimiter } from "../auth-rate-limit.js"; |
6 | 6 | import type { ResolvedGatewayAuth } from "../auth.js"; |
| 7 | +import { MAX_PAYLOAD_BYTES } from "../server-constants.js"; |
7 | 8 | import { VOICECLAW_REALTIME_PATH } from "./paths.js"; |
8 | 9 | import { VoiceClawRealtimeSession } from "./session.js"; |
9 | 10 | |
10 | 11 | export { VOICECLAW_REALTIME_PATH }; |
11 | 12 | |
12 | | -const wss = new WebSocketServer({ noServer: true }); |
| 13 | +export const VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES = MAX_PAYLOAD_BYTES; |
| 14 | + |
| 15 | +const wss = new WebSocketServer({ |
| 16 | +noServer: true, |
| 17 | +maxPayload: VOICECLAW_REALTIME_MAX_PAYLOAD_BYTES, |
| 18 | +}); |
13 | 19 | |
14 | 20 | export function handleVoiceClawRealtimeUpgrade(opts: { |
15 | 21 | req: IncomingMessage; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。