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

推荐订阅源

G
Google Developers Blog
博客园 - 聂微东
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
Jina AI
Jina AI
D
Docker
B
Blog
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Y
Y Combinator Blog
N
Netflix TechBlog - Medium
月光博客
月光博客
F
Fortinet All Blogs
爱范儿
爱范儿
H
Help Net Security
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
The Cloudflare Blog
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
U
Unit 42

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
refactor: share shutdown drain session setup · openclaw/o...
vincentkoc · 2026-06-01 · via Recent Commits to openclaw:main

@@ -62,6 +62,15 @@ const requireSessionEndHookEvent = (index: number): SessionEndHookEvent => {

6262

return call[0];

6363

};

646465+

function trackSessionForShutdown(params: { sessionId: string; sessionKey?: string }): void {

66+

emitGatewaySessionStartPluginHook({

67+

cfg,

68+

sessionKey: params.sessionKey ?? "agent:main:main",

69+

sessionId: params.sessionId,

70+

storePath: "/tmp/store.json",

71+

});

72+

}

73+6574

beforeEach(() => {

6675

clearActiveSessionsForShutdownTracker();

6776

runSessionEndMock.mockClear();

@@ -82,18 +91,8 @@ describe("drainActiveSessionsForShutdown", () => {

8291

});

83928493

it("fires session_end with reason=shutdown for every tracked session and clears them", async () => {

85-

emitGatewaySessionStartPluginHook({

86-

cfg,

87-

sessionKey: "agent:main:main",

88-

sessionId: "sess-A",

89-

storePath: "/tmp/store.json",

90-

});

91-

emitGatewaySessionStartPluginHook({

92-

cfg,

93-

sessionKey: "agent:main:other",

94-

sessionId: "sess-B",

95-

storePath: "/tmp/store.json",

96-

});

94+

trackSessionForShutdown({ sessionId: "sess-A" });

95+

trackSessionForShutdown({ sessionId: "sess-B", sessionKey: "agent:main:other" });

97969897

const result = await drainActiveSessionsForShutdown({ reason: "shutdown" });

9998

@@ -111,12 +110,7 @@ describe("drainActiveSessionsForShutdown", () => {

111110

});

112111113112

it("propagates reason=restart when called for a restart shutdown", async () => {

114-

emitGatewaySessionStartPluginHook({

115-

cfg,

116-

sessionKey: "agent:main:main",

117-

sessionId: "sess-A",

118-

storePath: "/tmp/store.json",

119-

});

113+

trackSessionForShutdown({ sessionId: "sess-A" });

120114121115

await drainActiveSessionsForShutdown({ reason: "restart" });

122116

@@ -125,18 +119,8 @@ describe("drainActiveSessionsForShutdown", () => {

125119

});

126120127121

it("does not double-fire for a session already finalized by reset/delete/compaction", async () => {

128-

emitGatewaySessionStartPluginHook({

129-

cfg,

130-

sessionKey: "agent:main:main",

131-

sessionId: "sess-A",

132-

storePath: "/tmp/store.json",

133-

});

134-

emitGatewaySessionStartPluginHook({

135-

cfg,

136-

sessionKey: "agent:main:other",

137-

sessionId: "sess-B",

138-

storePath: "/tmp/store.json",

139-

});

122+

trackSessionForShutdown({ sessionId: "sess-A" });

123+

trackSessionForShutdown({ sessionId: "sess-B", sessionKey: "agent:main:other" });

140124

// Simulate sess-A being finalized through the normal reset path before

141125

// the gateway is shut down: the matching `session_end` is fired with

142126

// reason="reset" and the tracker forgets it.

@@ -163,12 +147,7 @@ describe("drainActiveSessionsForShutdown", () => {

163147

runSessionEndMock.mockImplementationOnce(async () => {

164148

await handlerLatch;

165149

});

166-

emitGatewaySessionStartPluginHook({

167-

cfg,

168-

sessionKey: "agent:main:main",

169-

sessionId: "sess-A",

170-

storePath: "/tmp/store.json",

171-

});

150+

trackSessionForShutdown({ sessionId: "sess-A" });

172151173152

let drainSettled = false;

174153

const drainPromise = drainActiveSessionsForShutdown({ reason: "shutdown" }).then((value) => {

@@ -196,18 +175,8 @@ describe("drainActiveSessionsForShutdown", () => {

196175

await new Promise<void>(() => {});

197176

}

198177

});

199-

emitGatewaySessionStartPluginHook({

200-

cfg,

201-

sessionKey: "agent:main:main",

202-

sessionId: "sess-A",

203-

storePath: "/tmp/store.json",

204-

});

205-

emitGatewaySessionStartPluginHook({

206-

cfg,

207-

sessionKey: "agent:main:other",

208-

sessionId: "sess-B",

209-

storePath: "/tmp/store.json",

210-

});

178+

trackSessionForShutdown({ sessionId: "sess-A" });

179+

trackSessionForShutdown({ sessionId: "sess-B", sessionKey: "agent:main:other" });

211180212181

const result = await drainActiveSessionsForShutdown({

213182

reason: "shutdown",

@@ -224,12 +193,7 @@ describe("drainActiveSessionsForShutdown", () => {

224193225194

it("still records the session as forgotten when no `session_end` plugins are registered", async () => {

226195

hasHooksMock.mockImplementation(() => false);

227-

emitGatewaySessionStartPluginHook({

228-

cfg,

229-

sessionKey: "agent:main:main",

230-

sessionId: "sess-A",

231-

storePath: "/tmp/store.json",

232-

});

196+

trackSessionForShutdown({ sessionId: "sess-A" });

233197

// session_end fires while no plugin listens: hook is not run, but the

234198

// shutdown tracker must still forget the session so the later drain

235199

// does not pick it up.