惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
罗磊的独立博客
雷峰网
雷峰网
量子位
V
Visual Studio Blog
Vercel News
Vercel News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
月光博客
月光博客
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
腾讯CDC
Engineering at Meta
Engineering at Meta
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
Jina AI
Jina AI
A
About on SuperTechFans

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(openai): suppress realtime startup close callbacks · ...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main

@@ -22,6 +22,8 @@ const {

2222

sent: string[] = [];

2323

closed = false;

2424

terminated = false;

25+

deferClose = false;

26+

deferredClose: (() => void) | undefined;

2527

args: unknown[];

26282729

constructor(...args: unknown[]) {

@@ -49,13 +51,24 @@ const {

4951

close(code?: number, reason?: string): void {

5052

this.closed = true;

5153

this.readyState = MockWebSocket.CLOSED;

52-

this.emit("close", code ?? 1000, Buffer.from(reason ?? ""));

54+

const emitClose = () => this.emit("close", code ?? 1000, Buffer.from(reason ?? ""));

55+

if (this.deferClose) {

56+

this.deferredClose = emitClose;

57+

return;

58+

}

59+

emitClose();

5360

}

54615562

terminate(): void {

5663

this.terminated = true;

5764

this.close(1006, "terminated");

5865

}

66+67+

emitDeferredClose(): void {

68+

const emitClose = this.deferredClose;

69+

this.deferredClose = undefined;

70+

emitClose?.();

71+

}

5972

}

60736174

return {

@@ -924,11 +937,13 @@ describe("buildOpenAIRealtimeVoiceProvider", () => {

924937

it("treats pre-ready auth errors as a single startup failure", async () => {

925938

const provider = buildOpenAIRealtimeVoiceProvider();

926939

const onError = vi.fn();

940+

const onClose = vi.fn();

927941

const bridge = provider.createBridge({

928942

providerConfig: { apiKey: "sk-test" }, // pragma: allowlist secret

929943

onAudio: vi.fn(),

930944

onClearAudio: vi.fn(),

931945

onError,

946+

onClose,

932947

});

933948

const connecting = bridge.connect();

934949

const socket = FakeWebSocket.instances[0];

@@ -959,10 +974,58 @@ describe("buildOpenAIRealtimeVoiceProvider", () => {

959974960975

await expect(connecting).rejects.toThrow("Incorrect API key provided");

961976

expect(onError).not.toHaveBeenCalled();

977+

expect(onClose).not.toHaveBeenCalled();

962978

expect(socket.closed).toBe(true);

963979

expect(bridge.isConnected()).toBe(false);

964980

});

965981982+

it("keeps a retried connection ready after delayed startup failure close", async () => {

983+

const provider = buildOpenAIRealtimeVoiceProvider();

984+

const onClose = vi.fn();

985+

const bridge = provider.createBridge({

986+

providerConfig: { apiKey: "sk-test" }, // pragma: allowlist secret

987+

onAudio: vi.fn(),

988+

onClearAudio: vi.fn(),

989+

onClose,

990+

});

991+

const failedConnect = bridge.connect();

992+

const failedSocket = FakeWebSocket.instances[0];

993+

if (!failedSocket) {

994+

throw new Error("expected bridge to create a websocket");

995+

}

996+

failedSocket.deferClose = true;

997+998+

failedSocket.readyState = FakeWebSocket.OPEN;

999+

failedSocket.emit("open");

1000+

failedSocket.emit(

1001+

"message",

1002+

Buffer.from(

1003+

JSON.stringify({

1004+

type: "error",

1005+

error: { message: "Incorrect API key provided" },

1006+

}),

1007+

),

1008+

);

1009+1010+

await expect(failedConnect).rejects.toThrow("Incorrect API key provided");

1011+

expect(failedSocket.deferredClose).toBeDefined();

1012+1013+

const retryConnect = bridge.connect();

1014+

const retrySocket = FakeWebSocket.instances[1];

1015+

if (!retrySocket) {

1016+

throw new Error("expected bridge retry to create a websocket");

1017+

}

1018+

retrySocket.readyState = FakeWebSocket.OPEN;

1019+

retrySocket.emit("open");

1020+

retrySocket.emit("message", Buffer.from(JSON.stringify({ type: "session.updated" })));

1021+

await retryConnect;

1022+1023+

expect(bridge.isConnected()).toBe(true);

1024+

failedSocket.emitDeferredClose();

1025+

expect(bridge.isConnected()).toBe(true);

1026+

expect(onClose).not.toHaveBeenCalled();

1027+

});

1028+9661029

it("rejects connection when the socket closes before session readiness", async () => {

9671030

const provider = buildOpenAIRealtimeVoiceProvider();

9681031

const bridge = provider.createBridge({

@@ -984,6 +1047,33 @@ describe("buildOpenAIRealtimeVoiceProvider", () => {

9841047

expect(bridge.isConnected()).toBe(false);

9851048

});

98610491050+

it("does not report startup timeout shutdown as a clean close", async () => {

1051+

vi.useFakeTimers();

1052+

const provider = buildOpenAIRealtimeVoiceProvider();

1053+

const onClose = vi.fn();

1054+

const bridge = provider.createBridge({

1055+

providerConfig: { apiKey: "sk-test" }, // pragma: allowlist secret

1056+

onAudio: vi.fn(),

1057+

onClearAudio: vi.fn(),

1058+

onClose,

1059+

});

1060+

const connecting = bridge.connect();

1061+

const socket = FakeWebSocket.instances[0];

1062+

if (!socket) {

1063+

throw new Error("expected bridge to create a websocket");

1064+

}

1065+1066+

const timeoutAssertion = expect(connecting).rejects.toThrow(

1067+

"OpenAI realtime connection timeout",

1068+

);

1069+

await vi.advanceTimersByTimeAsync(10_000);

1070+

await timeoutAssertion;

1071+

expect(socket.terminated).toBe(true);

1072+

expect(onClose).not.toHaveBeenCalled();

1073+

expect(FakeWebSocket.instances).toHaveLength(1);

1074+

expect(bridge.isConnected()).toBe(false);

1075+

});

1076+9871077

it("can disable automatic audio turn responses for agent-routed voice loops", async () => {

9881078

const provider = buildOpenAIRealtimeVoiceProvider();

9891079

const bridge = provider.createBridge({