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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
爱范儿
爱范儿
The Cloudflare Blog
Y
Y Combinator Blog
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
G
Google Developers Blog
J
Java Code Geeks
P
Proofpoint News Feed
美团技术团队
Engineering at Meta
Engineering at Meta
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
有赞技术团队
有赞技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】

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): defer pricing refresh until ready · opencla...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -5,11 +5,13 @@ const hoisted = vi.hoisted(() => {

55

stop: vi.fn(),

66

updateConfig: vi.fn(),

77

};

8+

const stopModelPricingRefresh = vi.fn();

89

return {

910

heartbeatRunner,

1011

startHeartbeatRunner: vi.fn(() => heartbeatRunner),

1112

startChannelHealthMonitor: vi.fn(() => ({ stop: vi.fn() })),

12-

startGatewayModelPricingRefresh: vi.fn(() => vi.fn()),

13+

stopModelPricingRefresh,

14+

startGatewayModelPricingRefresh: vi.fn(() => stopModelPricingRefresh),

1315

loadModelPricingCacheModule: vi.fn(),

1416

isVitestRuntimeEnv: vi.fn(() => false),

1517

recoverPendingDeliveries: vi.fn(async () => undefined),

@@ -61,6 +63,7 @@ describe("server-runtime-services", () => {

6163

hoisted.startHeartbeatRunner.mockClear();

6264

hoisted.startChannelHealthMonitor.mockClear();

6365

hoisted.startGatewayModelPricingRefresh.mockClear();

66+

hoisted.stopModelPricingRefresh.mockClear();

6467

hoisted.loadModelPricingCacheModule.mockClear();

6568

hoisted.isVitestRuntimeEnv.mockReset().mockReturnValue(false);

6669

hoisted.recoverPendingDeliveries.mockClear();

@@ -69,14 +72,13 @@ describe("server-runtime-services", () => {

6972

});

70737174

it("skips model pricing bootstrap import when pricing is disabled", async () => {

72-

startGatewayRuntimeServices({

75+

activateGatewayScheduledServices({

7376

minimalTestGateway: false,

7477

cfgAtStart: { models: { pricing: { enabled: false } } } as never,

75-

channelManager: {

76-

getRuntimeSnapshot: vi.fn(),

77-

isHealthMonitorEnabled: vi.fn(),

78-

isManuallyStopped: vi.fn(),

79-

} as never,

78+

deps: {} as never,

79+

sessionDeliveryRecoveryMaxEnqueuedAt: 123,

80+

cron: { start: vi.fn(async () => undefined) },

81+

logCron: { error: vi.fn() },

8082

log: createLog(),

8183

});

8284

@@ -86,7 +88,7 @@ describe("server-runtime-services", () => {

8688

expect(hoisted.startGatewayModelPricingRefresh).not.toHaveBeenCalled();

8789

});

889089-

it("keeps scheduled services inert during initial runtime setup", async () => {

91+

it("keeps scheduled services and pricing refresh inert during initial runtime setup", async () => {

9092

const services = startGatewayRuntimeServices({

9193

minimalTestGateway: false,

9294

cfgAtStart: {} as never,

@@ -100,55 +102,62 @@ describe("server-runtime-services", () => {

100102101103

expect(hoisted.startChannelHealthMonitor).toHaveBeenCalledTimes(1);

102104

await vi.dynamicImportSettled();

103-

expect(hoisted.startGatewayModelPricingRefresh).toHaveBeenCalledWith({ config: {} });

105+

expect(hoisted.loadModelPricingCacheModule).not.toHaveBeenCalled();

106+

expect(hoisted.startGatewayModelPricingRefresh).not.toHaveBeenCalled();

104107

expect(hoisted.startHeartbeatRunner).not.toHaveBeenCalled();

105108

expect(hoisted.recoverPendingDeliveries).not.toHaveBeenCalled();

106109107110

services.heartbeatRunner.stop();

108111

expect(hoisted.heartbeatRunner.stop).not.toHaveBeenCalled();

109112

});

110113111-

it("passes startup plugin lookup metadata to the initial pricing refresh", async () => {

114+

it("starts model pricing refresh after scheduled services activate", async () => {

112115

const pluginLookUpTable = {

113116

index: { plugins: [] },

114117

manifestRegistry: { plugins: [], diagnostics: [] },

115118

};

119+

const cron = { start: vi.fn(async () => undefined) };

120+

const log = createLog();

116121117-

startGatewayRuntimeServices({

122+

const services = activateGatewayScheduledServices({

118123

minimalTestGateway: false,

119124

cfgAtStart: {} as never,

120-

channelManager: {

121-

getRuntimeSnapshot: vi.fn(),

122-

isHealthMonitorEnabled: vi.fn(),

123-

isManuallyStopped: vi.fn(),

124-

} as never,

125-

log: createLog(),

125+

deps: {} as never,

126+

sessionDeliveryRecoveryMaxEnqueuedAt: 123,

127+

cron,

128+

logCron: { error: vi.fn() },

129+

log,

126130

pluginLookUpTable: pluginLookUpTable as never,

127131

});

128132133+

expect(hoisted.startHeartbeatRunner).toHaveBeenCalledTimes(1);

134+

expect(cron.start).toHaveBeenCalledTimes(1);

129135

await vi.dynamicImportSettled();

130136

expect(hoisted.startGatewayModelPricingRefresh).toHaveBeenCalledWith({

131137

config: {},

132138

pluginLookUpTable,

133139

});

140+

services.stopModelPricingRefresh();

141+

expect(hoisted.stopModelPricingRefresh).toHaveBeenCalledTimes(1);

134142

});

135143136-

it("does not start model pricing refresh after early stop", async () => {

137-

const services = startGatewayRuntimeServices({

144+

it("does not start model pricing refresh after scheduled services stop before import settles", async () => {

145+

const cron = { start: vi.fn(async () => undefined) };

146+

const services = activateGatewayScheduledServices({

138147

minimalTestGateway: false,

139148

cfgAtStart: {} as never,

140-

channelManager: {

141-

getRuntimeSnapshot: vi.fn(),

142-

isHealthMonitorEnabled: vi.fn(),

143-

isManuallyStopped: vi.fn(),

144-

} as never,

149+

deps: {} as never,

150+

sessionDeliveryRecoveryMaxEnqueuedAt: 123,

151+

cron,

152+

logCron: { error: vi.fn() },

145153

log: createLog(),

146154

});

147155148156

services.stopModelPricingRefresh();

149157

await vi.dynamicImportSettled();

150158151159

expect(hoisted.startGatewayModelPricingRefresh).not.toHaveBeenCalled();

160+

expect(hoisted.stopModelPricingRefresh).not.toHaveBeenCalled();

152161

});

153162154163

it("activates heartbeat, cron, and delivery recovery after sidecars are ready", async () => {