mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 18:24:05 +00:00
Fix restart sentinel internal continuations (#88161)
* fix restart sentinel internal continuations * update gateway prompt snapshots * stabilize sandbox browser audit timer tests * drive sandbox audit timeouts deterministically * drive gh-read timeout tests deterministically * drive label-open-issues timeout tests deterministically * document deterministic timeout test timers * test: preserve deterministic timer setup after rebase
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
buildReadPermissions,
|
||||
githubJson,
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from "../../scripts/gh-read.js";
|
||||
|
||||
describe("gh-read helpers", () => {
|
||||
beforeEach(() => {
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
@@ -59,19 +59,27 @@ describe("gh-read helpers", () => {
|
||||
});
|
||||
|
||||
it("aborts stalled GitHub API fetches at the request timeout", async () => {
|
||||
vi.useFakeTimers();
|
||||
let signal: AbortSignal | undefined;
|
||||
let markFetchStarted!: () => void;
|
||||
const fetchStarted = new Promise<void>((resolve) => {
|
||||
markFetchStarted = resolve;
|
||||
});
|
||||
|
||||
vi.useFakeTimers();
|
||||
const request = githubJson("/app", "token", undefined, {
|
||||
timeoutMs: 5,
|
||||
fetchImpl: ((_url, init) => {
|
||||
signal = init?.signal ?? undefined;
|
||||
markFetchStarted();
|
||||
return new Promise(() => {});
|
||||
}) as typeof fetch,
|
||||
});
|
||||
const rejection = expect(request).rejects.toThrow(/GitHub API GET \/app exceeded timeout/u);
|
||||
|
||||
const rejected = expect(request).rejects.toThrow(/GitHub API GET \/app exceeded timeout/u);
|
||||
await fetchStarted;
|
||||
await vi.advanceTimersByTimeAsync(5);
|
||||
await rejected;
|
||||
|
||||
await rejection;
|
||||
expect(signal?.aborted).toBe(true);
|
||||
});
|
||||
|
||||
@@ -82,12 +90,13 @@ describe("gh-read helpers", () => {
|
||||
timeoutMs: 5,
|
||||
fetchImpl: (() => Promise.resolve(response)) as typeof fetch,
|
||||
});
|
||||
|
||||
const rejected = expect(request).rejects.toThrow(
|
||||
const rejection = expect(request).rejects.toThrow(
|
||||
/GitHub API GET \/app\/installations exceeded timeout/u,
|
||||
);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(5);
|
||||
await rejected;
|
||||
|
||||
await rejection;
|
||||
});
|
||||
|
||||
it("bounds GitHub API error response bodies", async () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { testing } from "../../scripts/label-open-issues.ts";
|
||||
|
||||
const labelItem = {
|
||||
@@ -9,6 +9,12 @@ const labelItem = {
|
||||
};
|
||||
|
||||
describe("label-open-issues helpers", () => {
|
||||
// Timeout tests below advance fake timers explicitly so CI shard load cannot
|
||||
// turn a bounded request-timeout assertion into a wall-clock wait.
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("classifies items from OpenAI structured response text", async () => {
|
||||
const response = new Response(
|
||||
JSON.stringify({
|
||||
@@ -37,34 +43,49 @@ describe("label-open-issues helpers", () => {
|
||||
|
||||
it("aborts stalled OpenAI classification fetches at the request timeout", async () => {
|
||||
let signal: AbortSignal | undefined;
|
||||
let markFetchStarted!: () => void;
|
||||
const fetchStarted = new Promise<void>((resolve) => {
|
||||
markFetchStarted = resolve;
|
||||
});
|
||||
|
||||
vi.useFakeTimers();
|
||||
const request = testing.classifyItem(labelItem, "issue", {
|
||||
apiKey: "test-key",
|
||||
model: "test-model",
|
||||
timeoutMs: 5,
|
||||
fetchImpl: ((_url, init) => {
|
||||
signal = init?.signal ?? undefined;
|
||||
markFetchStarted();
|
||||
return new Promise(() => {});
|
||||
}) as typeof fetch,
|
||||
});
|
||||
|
||||
await expect(request).rejects.toThrow(
|
||||
const rejection = expect(request).rejects.toThrow(
|
||||
/OpenAI issue label classification request exceeded timeout/u,
|
||||
);
|
||||
|
||||
await fetchStarted;
|
||||
await vi.advanceTimersByTimeAsync(5);
|
||||
|
||||
await rejection;
|
||||
expect(signal?.aborted).toBe(true);
|
||||
});
|
||||
|
||||
it("times out stalled OpenAI classification body reads", async () => {
|
||||
const response = new Response(new ReadableStream({}), { status: 200 });
|
||||
vi.useFakeTimers();
|
||||
const request = testing.classifyItem(labelItem, "issue", {
|
||||
apiKey: "test-key",
|
||||
model: "test-model",
|
||||
timeoutMs: 5,
|
||||
fetchImpl: (() => Promise.resolve(response)) as typeof fetch,
|
||||
});
|
||||
|
||||
await expect(request).rejects.toThrow(
|
||||
const rejection = expect(request).rejects.toThrow(
|
||||
/OpenAI issue label classification request exceeded timeout/u,
|
||||
);
|
||||
|
||||
await vi.advanceTimersByTimeAsync(5);
|
||||
|
||||
await rejection;
|
||||
});
|
||||
|
||||
it("bounds OpenAI error response bodies", async () => {
|
||||
|
||||
Reference in New Issue
Block a user