Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738// Node semantics for errors a request handler doesn't catch: the process dies with// exit code 1, and the request it was serving gets a 502 instead of hanging.import { test, expect, type Page } from "@playwright/test";import { appUrl } from "./http-golden";
async function crash(page: Page, path: string): Promise<number> { await page.goto("/demo/http.html"); await expect(page.frameLocator("#app").locator("#hi")).toBeVisible({ timeout: 20_000 }); return await page.evaluate(async (url) => (await fetch(url)).status, await appUrl(page) + path);}
test("an async handler that rejects kills the process instead of hanging the request", async ({ page }) => { const started = Date.now(); expect(await crash(page, "async-boom")).toBe(502); expect(Date.now() - started).toBeLessThan(5_000); await expect(page.locator("#exit")).toHaveText("1", { timeout: 20_000 }); await expect(page.locator("#err")).toContainText("Error: async boom");});
test("a sync throw in a handler is an uncaught exception", async ({ page }) => { expect(await crash(page, "boom")).toBe(502); await expect(page.locator("#exit")).toHaveText("1", { timeout: 20_000 }); await expect(page.locator("#err")).toContainText("Error: boom");});
test("a non-Error rejection reports ERR_UNHANDLED_REJECTION with the reason", async ({ page }) => { expect(await crash(page, "reject-string")).toBe(502); await expect(page.locator("#exit")).toHaveText("1", { timeout: 20_000 }); await expect(page.locator("#err")).toContainText('The promise rejected with the reason "nope".'); await expect(page.locator("#err")).toContainText("code: 'ERR_UNHANDLED_REJECTION'");});
test("after the crash the port is free", async ({ page }) => { expect(await crash(page, "boom")).toBe(502); await expect(page.locator("#exit")).toHaveText("1", { timeout: 20_000 }); expect(await page.evaluate(async (url) => (await fetch(url)).status, await appUrl(page))).toBe(502);});