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

推荐订阅源

V
V2EX
J
Java Code Geeks
月光博客
月光博客
博客园_首页
The GitHub Blog
The GitHub Blog
Vercel News
Vercel News
B
Blog RSS Feed
博客园 - 聂微东
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
Jina AI
Jina AI
S
SegmentFault 最新的问题
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
阮一峰的网络日志
阮一峰的网络日志
The Cloudflare Blog
量子位
Martin Fowler
Martin Fowler
博客园 - 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(msteams): stream graph success responses · openclaw/o...
vincentkoc · 2026-06-19 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -92,6 +92,33 @@ function mockTextFetchResponse(body: string, init?: ResponseInit) {

9292

mockFetch(async () => textResponse(body, init));

9393

}

9494
95+

function graphStreamResponse(body: unknown): {

96+

response: Response;

97+

arrayBuffer: ReturnType<typeof vi.fn>;

98+

} {

99+

const encoded = new TextEncoder().encode(JSON.stringify(body));

100+

const stream = new ReadableStream<Uint8Array>({

101+

start(controller) {

102+

controller.enqueue(encoded);

103+

controller.close();

104+

},

105+

});

106+

const arrayBuffer = vi.fn(async () => {

107+

throw new Error("Graph response must stay streaming");

108+

});

109+

return {

110+

response: {

111+

ok: true,

112+

status: 200,

113+

statusText: "OK",

114+

headers: new Headers({ "content-type": "application/json" }),

115+

body: stream,

116+

arrayBuffer,

117+

} as unknown as Response,

118+

arrayBuffer,

119+

};

120+

}

121+
95122

function graphCollection<T>(...items: T[]) {

96123

return { value: items };

97124

}

@@ -229,6 +256,20 @@ describe("msteams graph helpers", () => {

229256

);

230257

});

231258
259+

it("keeps successful Graph responses streaming for bounded JSON parsing", async () => {

260+

const { response, arrayBuffer } = graphStreamResponse(graphCollection(groupOne));

261+

mockFetch(async () => response);

262+
263+

await expect(

264+

fetchGraphJson<{ value: Array<{ id: string }> }>({

265+

token: graphToken,

266+

path: "/groups?$select=id",

267+

}),

268+

).resolves.toEqual(graphCollection(groupOne));

269+
270+

expect(arrayBuffer).not.toHaveBeenCalled();

271+

});

272+
232273

it("posts Graph JSON to v1 and beta roots and treats empty mutation responses as undefined", async () => {

233274

mockFetch(async (input) => {

234275

if (requestUrl(input).startsWith("https://graph.microsoft.com/beta")) {

Original file line numberDiff line numberDiff line change

@@ -31,6 +31,50 @@ type GraphChannel = {

3131
3232

export type GraphResponse<T> = { value?: T[] };

3333
34+

function responseWithRelease(response: Response, release: () => Promise<void>): Response {

35+

let released = false;

36+

const releaseOnce = async () => {

37+

if (released) {

38+

return;

39+

}

40+

released = true;

41+

await release();

42+

};

43+
44+

if (!response.body || NULL_BODY_STATUSES.has(response.status)) {

45+

void releaseOnce();

46+

return response;

47+

}

48+
49+

const reader = response.body.getReader();

50+

const body = new ReadableStream<Uint8Array>({

51+

async pull(controller) {

52+

try {

53+

const next = await reader.read();

54+

if (next.done) {

55+

controller.close();

56+

await releaseOnce();

57+

return;

58+

}

59+

controller.enqueue(next.value);

60+

} catch (error) {

61+

await releaseOnce();

62+

throw error;

63+

}

64+

},

65+

async cancel(reason) {

66+

void reader.cancel(reason).catch(() => undefined);

67+

await releaseOnce();

68+

},

69+

});

70+
71+

return new Response(body, {

72+

status: response.status,

73+

statusText: response.statusText,

74+

headers: response.headers,

75+

});

76+

}

77+
3478

export function normalizeQuery(value?: string | null): string {

3579

return value?.trim() ?? "";

3680

}

@@ -66,21 +110,20 @@ async function requestGraph(params: {

66110

},

67111

auditContext: "msteams.graph",

68112

});

113+

let releaseInFinally = true;

69114

try {

70115

if (!response.ok) {

71116

throw await createMSTeamsHttpError(

72117

response,

73118

`${params.errorPrefix ?? "Graph"} ${params.path} failed`,

74119

);

75120

}

76-

const body = NULL_BODY_STATUSES.has(response.status) ? null : await response.arrayBuffer();

77-

return new Response(body, {

78-

status: response.status,

79-

statusText: response.statusText,

80-

headers: new Headers(response.headers),

81-

});

121+

releaseInFinally = false;

122+

return responseWithRelease(response, release);

82123

} finally {

83-

await release();

124+

if (releaseInFinally) {

125+

await release();

126+

}

84127

}

85128

}

86129