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

推荐订阅源

博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
博客园_首页
C
Check Point Blog
小众软件
小众软件
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
美团技术团队
Martin Fowler
Martin Fowler
Vercel News
Vercel News
D
Docker
罗磊的独立博客
B
Blog RSS Feed
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
Last Week in AI
Last Week in AI
T
Tailwind CSS Blog
雷峰网
雷峰网
博客园 - Franky

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(gateway): clear stale chat stream buffers (#75089) · ...
litang9 · 2026-05-29 · via Recent Commits to openclaw:main

@@ -44,38 +44,63 @@ function createOps(params: {

4444

broadcast: ReturnType<typeof vi.fn>;

4545

nodeSendToSession: ReturnType<typeof vi.fn>;

4646

removeChatRun: ReturnType<typeof vi.fn>;

47+

clearedState: {

48+

chatDeltaSentAt: Map<string, number>;

49+

chatDeltaLastBroadcastLen: Map<string, number>;

50+

chatDeltaLastBroadcastText: Map<string, string>;

51+

agentDeltaSentAt: Map<string, number>;

52+

bufferedAgentEvents: Map<string, unknown>;

53+

};

4754

} {

4855

const { runId, entry, buffer } = params;

4956

const broadcast = vi.fn();

5057

const nodeSendToSession = vi.fn();

5158

const removeChatRun = vi.fn();

59+

const chatRunBuffers = new Map(buffer !== undefined ? [[runId, buffer]] : []);

60+

const chatDeltaSentAt = new Map([[runId, Date.now()]]);

61+

const chatDeltaLastBroadcastLen = new Map([[runId, buffer?.length ?? 0]]);

62+

const chatDeltaLastBroadcastText = new Map(buffer !== undefined ? [[runId, buffer]] : []);

63+

const agentDeltaSentAt = new Map([[`${runId}:assistant`, Date.now()]]);

64+

const bufferedAgentEvents = new Map<string, unknown>([

65+

[

66+

`${runId}:assistant`,

67+

{

68+

payload: {

69+

runId,

70+

seq: 1,

71+

stream: "assistant",

72+

ts: Date.now(),

73+

data: { text: "buffer", delta: "buffer" },

74+

},

75+

},

76+

],

77+

]);

52785379

return {

5480

chatAbortControllers: new Map([[runId, entry]]),

55-

chatRunBuffers: new Map(buffer !== undefined ? [[runId, buffer]] : []),

56-

chatDeltaSentAt: new Map([[runId, Date.now()]]),

57-

chatDeltaLastBroadcastLen: new Map([[runId, buffer?.length ?? 0]]),

58-

chatDeltaLastBroadcastText: new Map(buffer !== undefined ? [[runId, buffer]] : []),

59-

agentDeltaSentAt: new Map([[`${runId}:assistant`, Date.now()]]),

60-

bufferedAgentEvents: new Map([

61-

[

62-

`${runId}:assistant`,

63-

{

64-

payload: {

65-

runId,

66-

seq: 1,

67-

stream: "assistant",

68-

ts: Date.now(),

69-

data: { text: "buffer", delta: "buffer" },

70-

},

71-

},

72-

],

73-

]),

81+

chatRunBuffers,

7482

chatAbortedRuns: new Map(),

83+

clearChatRunState: (id: string) => {

84+

chatRunBuffers.delete(id);

85+

chatDeltaSentAt.delete(id);

86+

chatDeltaLastBroadcastLen.delete(id);

87+

chatDeltaLastBroadcastText.delete(id);

88+

for (const key of [id, `${id}:assistant`, `${id}:thinking`]) {

89+

agentDeltaSentAt.delete(key);

90+

bufferedAgentEvents.delete(key);

91+

}

92+

},

7593

removeChatRun,

7694

agentRunSeq: new Map(),

7795

broadcast,

7896

nodeSendToSession,

97+

clearedState: {

98+

chatDeltaSentAt,

99+

chatDeltaLastBroadcastLen,

100+

chatDeltaLastBroadcastText,

101+

agentDeltaSentAt,

102+

bufferedAgentEvents,

103+

},

79104

};

80105

}

81106

@@ -126,11 +151,11 @@ describe("abortChatRunById", () => {

126151

expect(entry.controller.signal.aborted).toBe(true);

127152

expect(ops.chatAbortControllers.has(runId)).toBe(false);

128153

expect(ops.chatRunBuffers.has(runId)).toBe(false);

129-

expect(ops.chatDeltaSentAt.has(runId)).toBe(false);

130-

expect(ops.chatDeltaLastBroadcastLen.has(runId)).toBe(false);

131-

expect(ops.chatDeltaLastBroadcastText.has(runId)).toBe(false);

132-

expect(ops.agentDeltaSentAt?.has(`${runId}:assistant`)).toBe(false);

133-

expect(ops.bufferedAgentEvents?.has(`${runId}:assistant`)).toBe(false);

154+

expect(ops.clearedState.chatDeltaSentAt.has(runId)).toBe(false);

155+

expect(ops.clearedState.chatDeltaLastBroadcastLen.has(runId)).toBe(false);

156+

expect(ops.clearedState.chatDeltaLastBroadcastText.has(runId)).toBe(false);

157+

expect(ops.clearedState.agentDeltaSentAt.has(`${runId}:assistant`)).toBe(false);

158+

expect(ops.clearedState.bufferedAgentEvents.has(`${runId}:assistant`)).toBe(false);

134159

expect(ops.removeChatRun).toHaveBeenCalledWith(runId, runId, sessionKey);

135160

expect(ops.agentRunSeq.has(runId)).toBe(false);

136161

expect(ops.agentRunSeq.has("client-run-1")).toBe(false);