fix(dev): dev server should not overtake app's root error handler (#3165)

This commit is contained in:
Marvin Hagemeister
2025-08-01 10:08:13 +02:00
committed by GitHub
parent a2de5154ec
commit 5f928d2cac
5 changed files with 71 additions and 5 deletions
+35
View File
@@ -353,6 +353,41 @@ export const app = new App().fsRoutes()`,
sanitizeResources: false,
});
Deno.test({
name: "Builder - dev server doesn't overtake _error handler",
fn: async () => {
const root = path.join(import.meta.dirname!, "..", "..");
await using _tmp = await withTmpDir({ dir: root, prefix: "tmp_builder_" });
const tmp = _tmp.dir;
const app = new App()
.onError("*", () => new Response("it works"))
.get("/", () => new Response("no"));
const builder = new Builder({
root: tmp,
outDir: path.join(tmp, "dist"),
});
const controller = new AbortController();
await builder.listen(() => Promise.resolve<App<unknown>>(app), {
signal: controller.signal,
async onListen(addr) {
const res = await fetch(`http://localhost:${addr.port}/invalid`);
const text = await res.text();
expect(text).toEqual("it works");
controller.abort();
},
});
// expect(text).toContain("<h1>ok</h1>");
},
sanitizeOps: false,
sanitizeResources: false,
});
Deno.test({
// Currently waiting on bug fixes in @deno/loader
// to support resolving without passing entry points