mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:10:43 +00:00
fix(discord): bound application summary probes
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { withFetchPreconnect } from "openclaw/plugin-sdk/test-env";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { fetchDiscordApplicationId, resolveDiscordPrivilegedIntentsFromFlags } from "./probe.js";
|
||||
import {
|
||||
fetchDiscordApplicationId,
|
||||
fetchDiscordApplicationSummary,
|
||||
resolveDiscordPrivilegedIntentsFromFlags,
|
||||
} from "./probe.js";
|
||||
import { jsonResponse } from "./test-http-helpers.js";
|
||||
|
||||
describe("resolveDiscordPrivilegedIntentsFromFlags", () => {
|
||||
@@ -58,6 +62,22 @@ describe("resolveDiscordPrivilegedIntentsFromFlags", () => {
|
||||
expect(calls).toBe(2);
|
||||
});
|
||||
|
||||
it("does not retry Cloudflare HTML rate limits during application summary probes", async () => {
|
||||
let calls = 0;
|
||||
const fetcher = withFetchPreconnect(async () => {
|
||||
calls += 1;
|
||||
return new Response("<html><title>Error 1015</title></html>", {
|
||||
status: 429,
|
||||
headers: { "content-type": "text/html" },
|
||||
});
|
||||
});
|
||||
|
||||
await expect(
|
||||
fetchDiscordApplicationSummary("unparseable.token", 1_000, fetcher),
|
||||
).resolves.toBeUndefined();
|
||||
expect(calls).toBe(1);
|
||||
});
|
||||
|
||||
it("derives application id from parseable tokens before probing REST", async () => {
|
||||
let calls = 0;
|
||||
const fetcher = withFetchPreconnect(async () => {
|
||||
|
||||
@@ -49,6 +49,7 @@ async function fetchDiscordApplicationMe(
|
||||
"/oauth2/applications/@me",
|
||||
normalized,
|
||||
createDiscordTimeoutFetch(fetcher, timeoutMs),
|
||||
{ retry: { attempts: 1 } },
|
||||
);
|
||||
} catch {
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user