mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-09 03:22:40 +00:00
fix(release): cancel Discord cleanup bodies
This commit is contained in:
@@ -2741,16 +2741,21 @@ async function postDiscordMessage(params) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteDiscordMessage(params) {
|
||||
export async function deleteDiscordMessage(params) {
|
||||
if (!params.messageId) {
|
||||
return;
|
||||
}
|
||||
await fetch(
|
||||
`https://discord.com/api/v10/channels/${params.channelId}/messages/${params.messageId}`,
|
||||
buildDiscordFetchInit(params.token, {
|
||||
method: "DELETE",
|
||||
}),
|
||||
).catch(() => undefined);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://discord.com/api/v10/channels/${params.channelId}/messages/${params.messageId}`,
|
||||
buildDiscordFetchInit(params.token, {
|
||||
method: "DELETE",
|
||||
}),
|
||||
);
|
||||
await response.body?.cancel?.().catch(() => undefined);
|
||||
} catch {
|
||||
// Cleanup is best-effort; the smoke result should not fail after readback succeeds.
|
||||
}
|
||||
}
|
||||
|
||||
async function waitForInstalledDiscordReadback(params) {
|
||||
|
||||
@@ -50,6 +50,7 @@ import {
|
||||
CROSS_OS_DISCORD_FETCH_TIMEOUT_MS,
|
||||
CROSS_OS_AGENT_TURN_TIMEOUT_SECONDS,
|
||||
CROSS_OS_COMMAND_HEARTBEAT_SECONDS,
|
||||
deleteDiscordMessage,
|
||||
isImmutableReleaseRef,
|
||||
isRecoverableWindowsPackagedUpgradeSwapCleanupFailure,
|
||||
isRecoverableWindowsPackagedUpgradeTimeoutError,
|
||||
@@ -1470,6 +1471,31 @@ describe("scripts/openclaw-cross-os-release-checks", () => {
|
||||
expect(init.signal).toBeInstanceOf(AbortSignal);
|
||||
});
|
||||
|
||||
it("cancels Discord delete response bodies", async () => {
|
||||
let canceled = false;
|
||||
const originalFetch = globalThis.fetch;
|
||||
globalThis.fetch = (async () =>
|
||||
new Response(
|
||||
new ReadableStream<Uint8Array>({
|
||||
cancel() {
|
||||
canceled = true;
|
||||
},
|
||||
}),
|
||||
{ status: 200 },
|
||||
)) as typeof fetch;
|
||||
try {
|
||||
await deleteDiscordMessage({
|
||||
channelId: "channel-123",
|
||||
messageId: "message-456",
|
||||
token: "discord-token",
|
||||
});
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
|
||||
expect(canceled).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps the dev-update lane for main only", () => {
|
||||
expect(shouldRunMainChannelDevUpdate("main")).toBe(true);
|
||||
expect(shouldRunMainChannelDevUpdate("08753a1d793c040b101c8a26c43445dbbab14995")).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user