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

推荐订阅源

宝玉的分享
宝玉的分享
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
Y
Y Combinator Blog
月光博客
月光博客
IT之家
IT之家
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
L
LangChain Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
博客园 - Franky
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
V
Visual Studio Blog
小众软件
小众软件
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium

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(providers): bound self-hosted provider discovery JSON...
Alix-007 · 2026-06-25 · via Recent Commits to openclaw:main

@@ -23,6 +23,42 @@ beforeEach(() => {

2323

vi.clearAllMocks();

2424

});

252526+

// Mirrors SELF_HOSTED_DISCOVERY_JSON_MAX_BYTES in the source under test. Kept in

27+

// sync deliberately so the regression asserts the body is capped, not drained.

28+

const SELF_HOSTED_DISCOVERY_JSON_MAX_BYTES = 16 * 1024 * 1024;

29+

const CHUNK_BYTES = 1024 * 1024;

30+31+

/**

32+

* Builds a Response body that would never terminate on its own: each pull emits

33+

* a 1 MiB chunk forever. A bounded reader must cancel it after the byte cap.

34+

*/

35+

function createUnboundedJsonStream(): {

36+

body: ReadableStream<Uint8Array>;

37+

cancelCount: number;

38+

bytesPulled: number;

39+

} {

40+

const state = { cancelCount: 0, bytesPulled: 0 };

41+

const chunk = new Uint8Array(CHUNK_BYTES).fill(0x20); // ASCII spaces: valid stream, never closes

42+

const body = new ReadableStream<Uint8Array>({

43+

pull(controller) {

44+

state.bytesPulled += chunk.byteLength;

45+

controller.enqueue(chunk);

46+

},

47+

cancel() {

48+

state.cancelCount += 1;

49+

},

50+

});

51+

return {

52+

body,

53+

get cancelCount() {

54+

return state.cancelCount;

55+

},

56+

get bytesPulled() {

57+

return state.bytesPulled;

58+

},

59+

};

60+

}

61+2662

function createRuntime() {

2763

return {

2864

error: vi.fn(),

@@ -437,6 +473,75 @@ describe("discoverOpenAICompatibleLocalModels", () => {

437473

});

438474

expect(release).toHaveBeenCalledOnce();

439475

});

476+477+

it("bounds an unbounded /models discovery stream instead of buffering it", async () => {

478+

const release = vi.fn(async () => undefined);

479+

const oversized = createUnboundedJsonStream();

480+

fetchWithSsrFGuardMock.mockResolvedValueOnce({

481+

response: new Response(oversized.body, { status: 200 }),

482+

finalUrl: "http://127.0.0.1:8000/v1/models",

483+

release,

484+

});

485+486+

const models = await discoverOpenAICompatibleLocalModels({

487+

baseUrl: "http://127.0.0.1:8000/v1",

488+

label: "vLLM",

489+

env: {},

490+

});

491+492+

// The reader cancels the body once the byte cap is exceeded; without the

493+

// cap the stream would never finish and the discovery would buffer it all.

494+

expect(models).toEqual([]);

495+

expect(oversized.cancelCount).toBe(1);

496+

expect(oversized.bytesPulled).toBeLessThanOrEqual(

497+

SELF_HOSTED_DISCOVERY_JSON_MAX_BYTES + 2 * CHUNK_BYTES,

498+

);

499+

expect(release).toHaveBeenCalledOnce();

500+

});

501+502+

it("bounds an unbounded llama.cpp /props discovery stream instead of buffering it", async () => {

503+

const modelsRelease = vi.fn(async () => undefined);

504+

const propsRelease = vi.fn(async () => undefined);

505+

const oversized = createUnboundedJsonStream();

506+

fetchWithSsrFGuardMock.mockResolvedValueOnce({

507+

response: new Response(JSON.stringify({ data: [{ id: "qwen3.6-mxfp4-moe" }] }), {

508+

status: 200,

509+

}),

510+

finalUrl: "http://127.0.0.1:8080/v1/models",

511+

release: modelsRelease,

512+

});

513+

fetchWithSsrFGuardMock.mockResolvedValueOnce({

514+

response: new Response(oversized.body, { status: 200 }),

515+

finalUrl: "http://127.0.0.1:8080/props",

516+

release: propsRelease,

517+

});

518+519+

const models = await discoverOpenAICompatibleLocalModels({

520+

baseUrl: "http://127.0.0.1:8080/v1",

521+

label: "llama.cpp",

522+

env: {},

523+

});

524+525+

// /props overflow is swallowed so discovery still succeeds, but the body is

526+

// capped: the runtime context token probe is skipped, not OOM'd.

527+

expect(models).toEqual([

528+

{

529+

id: "qwen3.6-mxfp4-moe",

530+

name: "qwen3.6-mxfp4-moe",

531+

reasoning: false,

532+

input: ["text"],

533+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

534+

contextWindow: 128000,

535+

maxTokens: 8192,

536+

},

537+

]);

538+

expect(oversized.cancelCount).toBe(1);

539+

expect(oversized.bytesPulled).toBeLessThanOrEqual(

540+

SELF_HOSTED_DISCOVERY_JSON_MAX_BYTES + 2 * CHUNK_BYTES,

541+

);

542+

expect(modelsRelease).toHaveBeenCalledOnce();

543+

expect(propsRelease).toHaveBeenCalledOnce();

544+

});

440545

});

441546442547

describe("configureOpenAICompatibleSelfHostedProviderNonInteractive", () => {