test: fix the Claude listing heap test and the hero opening-scene race (#11204)

The Claude listing heap test capped its child at 96 MB, but most of
that budget went to loading the modules. Since prompt attachments
import the file-upload module, agent.ts also loads the protocol message
schemas, about 50 MB more. The 14 MB listing then ran out of heap on
runs where GC ran late. The test now measures what the imports retain
in a first child, then caps the listing child at that plus 64 MiB. That
is still below the 128 MiB transcript, so loading a whole history still
runs out of heap.

The opening-scene tests advanced the paused page clock once, right
after the scroll. The scene starts a few page tasks later
(IntersectionObserver, then a React render and effect). When the clock
advance ran first, the scene started on a paused clock and the request
never appeared. The tests now advance the clock in 1 s steps until the
request shows.

CI also uploads the website Playwright results when that step fails,
so the next stall has a trace.
This commit is contained in:
Mohamed Boudra
2026-11-28 22:40:58 +07:00
committed by GitHub
parent 635df88fa6
commit 6916ceee47
3 changed files with 53 additions and 9 deletions
+9
View File
@@ -217,6 +217,15 @@ jobs:
- name: Verify website mockups
run: npm run test:e2e --workspace=@getpaseo/website
- name: Upload website test artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: website-playwright-results
path: packages/website/test-results/
if-no-files-found: ignore
retention-days: 7
- name: Verify public package contents
run: |
npm pack --dry-run --ignore-scripts --workspace=@getpaseo/protocol
@@ -2847,18 +2847,37 @@ describe("ClaudeAgentClient.listImportableSessions", () => {
await transcript.close();
}
const childImports = `
import { deepStrictEqual } from "node:assert";
import { ClaudeAgentClient } from ${JSON.stringify(new URL("./agent.ts", import.meta.url).href)};
import pino from ${JSON.stringify(import.meta.resolve("pino"))};
`;
// Cap the listing at its own budget on top of what loading the modules retains. A fixed
// cap also counted the module graph, which grows with unrelated imports.
const { stdout: loadedHeap } = await promisify(execFile)(process.execPath, [
"--expose-gc",
"--import",
import.meta.resolve("tsx"),
"--input-type=module",
"--eval",
`${childImports}
globalThis.gc();
console.log(process.memoryUsage().heapUsed);
`,
]);
// Well under the 128 MiB transcript, so loading a whole history still runs out of heap.
const listingBudgetMiB = 64;
const heapCapMiB = Math.ceil(Number(loadedHeap) / (1024 * 1024)) + listingBudgetMiB;
const { stdout } = await promisify(execFile)(
process.execPath,
[
"--max-old-space-size=96",
`--max-old-space-size=${heapCapMiB}`,
"--import",
import.meta.resolve("tsx"),
"--input-type=module",
"--eval",
`
import { deepStrictEqual } from "node:assert";
import { ClaudeAgentClient } from ${JSON.stringify(new URL("./agent.ts", import.meta.url).href)};
import pino from ${JSON.stringify(import.meta.resolve("pino"))};
`${childImports}
import { mkdir, symlink } from "node:fs/promises";
import path from "node:path";
const clients = [];
+20 -4
View File
@@ -26,6 +26,24 @@ async function centerMockup(mockup: Locator) {
);
}
/**
* Plays the scene clock until `shows` is visible. Bringing the mockup on screen starts the opening
* scene a few page tasks later: the start line's IntersectionObserver fires, then React runs the
* effect that starts the player. A clock advance sent right after the scroll can run before that.
*/
async function playUntilVisible(page: Page, shows: Locator) {
await expect
.poll(
async () => {
await page.clock.runFor(1000);
return shows.isVisible();
},
// The page clock is paused, so waiting between checks only spends the test's time.
{ intervals: [0], timeout: 15_000 },
)
.toBe(true);
}
async function finishPanelSwap(page: Page, mockup: Locator, outgoingPanel: Locator) {
await expect
.poll(async () => {
@@ -178,8 +196,7 @@ test("the opening scene waits until most of the mockup is on screen", async ({ p
await centerMockup(mockup);
await expect(mockup).toBeInViewport({ ratio: 0.6 });
await page.clock.runFor(4500);
await expect(request).toBeVisible();
await playUntilVisible(page, request);
});
test("the opening scene starts in a window shorter than most of the mockup", async ({ page }) => {
@@ -189,8 +206,7 @@ test("the opening scene starts in a window shorter than most of the mockup", asy
await centerMockup(mockup);
await expect(mockup).toBeInViewport();
await expect(mockup).not.toBeInViewport({ ratio: 0.6 });
await page.clock.runFor(4500);
await expect(request).toBeVisible();
await playUntilVisible(page, request);
});
test("the plugins scene installs the panel, then changes it on request", async ({ page }) => {