




















@@ -19,6 +19,7 @@ import {
1919collectConfiguredModelPricingRefs,
2020getCachedGatewayModelPricing,
2121refreshGatewayModelPricingCache,
22+startGatewayModelPricingRefresh,
2223} from "./model-pricing-cache.js";
23242425describe("model-pricing-cache", () => {
@@ -519,6 +520,39 @@ describe("model-pricing-cache", () => {
519520});
520521});
521522523+it("defers bootstrap refresh work until after the starter returns", async () => {
524+const config = {
525+agents: {
526+defaults: {
527+model: { primary: "anthropic/claude-opus-4-6" },
528+},
529+},
530+} as unknown as OpenClawConfig;
531+const fetchImpl = withFetchPreconnect(
532+vi.fn(async (input: RequestInfo | URL) => {
533+const url =
534+typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
535+if (url.includes("openrouter.ai")) {
536+return new Response(JSON.stringify({ data: [] }), {
537+status: 200,
538+headers: { "Content-Type": "application/json" },
539+});
540+}
541+return new Response(JSON.stringify({}), {
542+status: 200,
543+headers: { "Content-Type": "application/json" },
544+});
545+}),
546+);
547+548+const stop = startGatewayModelPricingRefresh({ config, fetchImpl });
549+550+expect(fetchImpl).not.toHaveBeenCalled();
551+await vi.dynamicImportSettled();
552+expect(fetchImpl).toHaveBeenCalled();
553+stop();
554+});
555+522556it("logs configured timeout seconds when pricing fetches time out", async () => {
523557const warnings: string[] = [];
524558loggingState.rawConsole = {
@@ -549,10 +583,10 @@ describe("model-pricing-cache", () => {
549583expect(warnings).toEqual(
550584expect.arrayContaining([
551585expect.stringContaining(
552-"OpenRouter pricing fetch failed (timeout 15s): TimeoutError: The operation was aborted due to timeout",
586+"OpenRouter pricing fetch failed (timeout 30s): TimeoutError: The operation was aborted due to timeout",
553587),
554588expect.stringContaining(
555-"LiteLLM pricing fetch failed (timeout 15s): TimeoutError: The operation was aborted due to timeout",
589+"LiteLLM pricing fetch failed (timeout 30s): TimeoutError: The operation was aborted due to timeout",
556590),
557591]),
558592);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。