From 001938ff329a65c8c4e8a2a6bbf91464441acf00 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 20 Jul 2024 15:15:35 -0700 Subject: [PATCH] chore: dont crash for non-existent asset requests --- packages/diagnostic/server/bun/fetch.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/diagnostic/server/bun/fetch.js b/packages/diagnostic/server/bun/fetch.js index 6f797dc531d..e13886f8dda 100644 --- a/packages/diagnostic/server/bun/fetch.js +++ b/packages/diagnostic/server/bun/fetch.js @@ -60,6 +60,13 @@ export function handleBunFetch(config, state, req, server) { // serve test assets debug(`Serving asset ${route} for browser ${bId} window ${wId}`); - return new Response(Bun.file(path.join(process.cwd(), config.assets, route))); + const asset = Bun.file(path.join(process.cwd(), config.assets, route)); + + return asset.exists().then((exists) => { + if (!exists) { + return new Response('Not Found', { status: 404 }); + } + new Response(asset); + }); } }