



















@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync
33import { tmpdir } from "node:os";
44import path from "node:path";
55import { setTimeout as delay } from "node:timers/promises";
6-import { describe, expect, it, vi } from "vitest";
6+import { afterEach, describe, expect, it, vi } from "vitest";
77import {
88appendBoundedOutput,
99assertDiagnosticStabilityClean,
@@ -23,6 +23,10 @@ import {
23232424const posixIt = process.platform === "win32" ? it.skip : it;
252526+afterEach(() => {
27+vi.useRealTimers();
28+});
29+2630describe("kitchen-sink RPC isolated state", () => {
2731it("cleans up the generated temporary home tree", async () => {
2832const { root, env } = makeEnv();
@@ -459,6 +463,29 @@ describe("kitchen-sink RPC process sampling", () => {
459463expect(fetchImpl).toHaveBeenCalledTimes(2);
460464});
461465466+it("times out stalled HTTP probe response bodies", async () => {
467+vi.useFakeTimers();
468+const fetchImpl = vi.fn().mockResolvedValue({
469+ok: true,
470+status: 200,
471+text: () => new Promise(() => undefined),
472+});
473+474+const result = fetchJson("http://127.0.0.1:19680/readyz", {
475+attempts: 1,
476+ fetchImpl,
477+timeoutMs: 100,
478+});
479+const rejection = expect(result).rejects.toMatchObject({
480+code: "ETIMEDOUT",
481+message: "fetch http://127.0.0.1:19680/readyz timed out after 100ms",
482+});
483+484+await vi.advanceTimersByTimeAsync(100);
485+await rejection;
486+expect(fetchImpl.mock.calls[0]?.[1]?.signal.aborted).toBe(true);
487+});
488+462489it("fails when the sampled RSS exceeds the configured ceiling", () => {
463490expect(() => assertResourceCeiling({ rssMiB: 2049 })).toThrow(
464491"gateway RSS exceeded 2048 MiB: 2049 MiB",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。