mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
Reduce PTY output in the terminal socket overflow test (#10843)
* test(terminal): reduce PTY output needed to exercise socket overflow The terminal must finish writing before the stalled controller resumes. Use enough output to force the 4 MiB queue limit while reducing the load on Windows runners. * test(terminal): assert both markers survive socket overflow Write the overflow burst to the alternate screen so it does not scroll the startup marker out of the replay window. Use distinct markers to exercise replay across the disconnect. --------- Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
This commit is contained in:
@@ -2339,21 +2339,30 @@ it.each(["replacement", "socket-overflow"] as const)(
|
||||
async (loss) => {
|
||||
const paseoHome = createTemporaryHome();
|
||||
const drained = join(paseoHome, "burst-drained");
|
||||
// The worker closes its controller socket above 4 MiB of queued writes.
|
||||
// Leave room for bytes already in the pipe.
|
||||
const burstMiB = 8;
|
||||
manager = await startRealWorkerManager({ paseoHome });
|
||||
const session = trackTerminal(
|
||||
await manager.createTerminal({
|
||||
cwd: paseoHome,
|
||||
workspaceId: "attached-reconnect",
|
||||
...nodeTerminalCommand(
|
||||
`process.stdout.write("RETAINED\\r\\n"); process.stdin.on("data", data => {
|
||||
if (data.toString().includes("BURST")) process.stdout.write("x".repeat(12 * 1024 * 1024) + "\\r\\nRETAINED-AFTER-LOSS\\r\\n", () => require("node:fs").writeFileSync(${JSON.stringify(drained)}, "done"));
|
||||
else process.stdout.write("ECHO:" + data);
|
||||
`process.stdout.write("BEFORE-LOSS\\r\\n"); process.stdin.on("data", data => {
|
||||
if (data.toString().includes("BURST")) {
|
||||
// Keep the startup line in the main screen while filling the socket.
|
||||
const burst = "\\x1b[?1049h" + "x".repeat(${burstMiB} * 1024 * 1024);
|
||||
process.stdout.write(burst + "\\x1b[?1049lAFTER-LOSS\\r\\n", () => {
|
||||
require("node:fs").writeFileSync(${JSON.stringify(drained)}, "done");
|
||||
});
|
||||
} else process.stdout.write("ECHO:" + data);
|
||||
}); setInterval(() => {}, 1000);`,
|
||||
),
|
||||
}),
|
||||
);
|
||||
await waitForCondition(
|
||||
async () => (await manager!.captureTerminal(session.id)).lines.join("").includes("RETAINED"),
|
||||
async () =>
|
||||
(await manager!.captureTerminal(session.id)).lines.join("").includes("BEFORE-LOSS"),
|
||||
10000,
|
||||
);
|
||||
const viewers = terminalViewers(manager, session.id);
|
||||
@@ -2376,15 +2385,15 @@ it.each(["replacement", "socket-overflow"] as const)(
|
||||
const stall = new Int32Array(new SharedArrayBuffer(4));
|
||||
const deadline = Date.now() + 10000;
|
||||
while (!existsSync(drained) && Date.now() < deadline) Atomics.wait(stall, 0, 0, 25);
|
||||
expect(existsSync(drained)).toBe(true);
|
||||
expect(existsSync(drained), "terminal finished writing the overflow burst").toBe(true);
|
||||
}
|
||||
await waitForCondition(() => viewers.replayed(desktop), 10000);
|
||||
const replay = viewers.frames
|
||||
.filter((row) => row.frame.opcode === TerminalStreamOpcode.ReplayData)
|
||||
.map((row) => Buffer.from(row.frame.payload).toString("utf8"))
|
||||
.join("");
|
||||
expect(replay).toContain("RETAINED");
|
||||
if (loss === "socket-overflow") expect(replay).toContain("RETAINED-AFTER-LOSS");
|
||||
expect(replay).toContain("BEFORE-LOSS");
|
||||
if (loss === "socket-overflow") expect(replay).toContain("AFTER-LOSS");
|
||||
expect((await workerRecords(paseoHome)).map((worker) => worker.pid)).toEqual([record!.pid]);
|
||||
session.send({ type: "input", data: "RECOVERED\r" });
|
||||
await waitForCondition(() => viewers.text(desktop).includes("ECHO:RECOVERED"), 3000);
|
||||
|
||||
Reference in New Issue
Block a user