/** * ROUTES-AUDIT 13 (coordinator, 23 Nov 2026): the internal header `x-cotton-fault` (what threw, with its stack frames) * reached outside callers through the open host's own error path and through forwards that skipped `toldFault`. Now * every answer leaves through the Worker's one fetch, which logs the fault and takes the header off. */import { env } from"cloudflare:test";import { describe, expect, it } from"vitest";import worker from"../src/index.ts";import { FAULT_HEADER } from"../src/http.ts";importtype { Env } from"../src/env.ts";describe("an unexpected error", () => { it("never carries what threw to an outside caller, at the open host or an object's door", async () => {// The open door, its directory missing: it throws something that is not a refusal.const broken = { ...(env as unknown asEnv), DIRECTORY: undefined } as unknown asEnv;const open = await worker.fetch(newRequest("https://cottondb.com/v1/code", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ phone: "+919000008001", device_id: "d" }) }), broken); expect(open.status).toBe(500); expect(open.headers.get(FAULT_HEADER)).toBeNull(); expect(await open.text()).not.toMatch(/at |TypeError|\.ts:/); });});