Skip to content

Commit 51409b8

Browse files
hclsysclaude
andcommitted
fix(msteams): add fetch timeout to Microsoft Graph API calls
fetchGraphJson() had no timeout, so a hanging Microsoft Graph endpoint would stall the entire MS Teams extension indefinitely. Add a 30-second AbortSignal.timeout and wrap the fetch in a try/catch that preserves the cause chain. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: HCL <[email protected]>
1 parent 1f50fed commit 51409b8

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

extensions/msteams/src/graph.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,21 @@ export async function fetchGraphJson<T>(params: {
3636
path: string;
3737
headers?: Record<string, string>;
3838
}): Promise<T> {
39-
const res = await fetch(`${GRAPH_ROOT}${params.path}`, {
40-
headers: {
41-
Authorization: `Bearer ${params.token}`,
42-
...params.headers,
43-
},
44-
});
39+
let res: Response;
40+
try {
41+
res = await fetch(`${GRAPH_ROOT}${params.path}`, {
42+
headers: {
43+
Authorization: `Bearer ${params.token}`,
44+
...params.headers,
45+
},
46+
signal: AbortSignal.timeout(30_000),
47+
});
48+
} catch (err) {
49+
throw new Error(
50+
`Graph ${params.path} request failed: ${err instanceof Error ? err.message : String(err)}`,
51+
{ cause: err },
52+
);
53+
}
4554
if (!res.ok) {
4655
const text = await res.text().catch(() => "");
4756
throw new Error(`Graph ${params.path} failed (${res.status}): ${text || "unknown error"}`);

0 commit comments

Comments
 (0)