Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
12345678910111213141516171819202122232425262728// proc.kill(): a supervisor restarting a live server needs to stop it first.import { test, expect } from "@playwright/test";import "./guest";
test("kill ends a listening server with 143, frees its port, and is a no-op afterwards", async ({ page }) => { await page.goto("/demo/fixture.html"); await page.waitForFunction(() => window.__runtime !== undefined, undefined, { timeout: 20_000 }); const result = await page.evaluate(async () => { const runtime = window.__runtime!; const log: string[] = []; runtime.onUnlistening((port) => log.push(`close ${port}`)); runtime.writeTree({ "/app/srv.cjs": 'require("node:http").createServer((q, s) => s.end()).listen(4400);' }); const first = runtime.exec("/app/srv.cjs"); const url = await runtime.waitForPort(4400); first.kill(); log.push(`exit ${await first.exited}`); first.kill(); const status = (await fetch(url)).status; const second = runtime.exec("/app/srv.cjs"); await runtime.waitForPort(4400); const answered = (await fetch(url)).ok; second.kill(); log.push(`exit ${await second.exited}`); return { log, status, answered }; }); expect(result).toEqual({ log: ["close 4400", "exit 143", "close 4400", "exit 143"], status: 502, answered: true });});