fix(discord): cancel failed probe response bodies · openclaw/openclaw@e67f8ba
vincentkoc
·
2026-06-19
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,6 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
4 | 4 | import { |
5 | 5 | fetchDiscordApplicationId, |
6 | 6 | fetchDiscordApplicationSummary, |
| 7 | +probeDiscord, |
7 | 8 | resolveDiscordPrivilegedIntentsFromFlags, |
8 | 9 | } from "./probe.js"; |
9 | 10 | import { jsonResponse } from "./test-http-helpers.js"; |
@@ -89,6 +90,20 @@ describe("resolveDiscordPrivilegedIntentsFromFlags", () => {
|
89 | 90 | expect(calls).toBe(1); |
90 | 91 | }); |
91 | 92 | |
| 93 | +it("cancels failed getMe probe response bodies", async () => { |
| 94 | +const cancel = vi.fn(async () => undefined); |
| 95 | +const fetcher = withFetchPreconnect( |
| 96 | +async () => ({ ok: false, status: 401, body: { cancel } }) as unknown as Response, |
| 97 | +); |
| 98 | + |
| 99 | +await expect(probeDiscord("MTIz.abc.def", 1_000, { fetcher })).resolves.toMatchObject({ |
| 100 | +ok: false, |
| 101 | +status: 401, |
| 102 | +error: "getMe failed (401)", |
| 103 | +}); |
| 104 | +expect(cancel).toHaveBeenCalledTimes(1); |
| 105 | +}); |
| 106 | + |
92 | 107 | it("derives application id from parseable tokens before probing REST", async () => { |
93 | 108 | let calls = 0; |
94 | 109 | const fetcher = withFetchPreconnect(async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。