From 402c77d6be1dc7e797afb20893d2862c96f0343a Mon Sep 17 00:00:00 2001 From: Jesse Kriss Date: Tue, 18 Jan 2022 14:58:27 -0800 Subject: [PATCH] Fix silent failure when browser open doesn't work (#263) * Fix the error case when "open" fails It's the returned child process that throws an error, not the launching function itself * Fixing accidental console log * Adding changeset and fixing formatting * Update pages.tsx Co-authored-by: Sunil Pai --- .changeset/tricky-lemons-warn.md | 5 +++++ packages/wrangler/src/pages.tsx | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/tricky-lemons-warn.md diff --git a/.changeset/tricky-lemons-warn.md b/.changeset/tricky-lemons-warn.md new file mode 100644 index 000000000000..c4947a560131 --- /dev/null +++ b/.changeset/tricky-lemons-warn.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +fix: appropriately fail silently when the open browser command doesn't work diff --git a/packages/wrangler/src/pages.tsx b/packages/wrangler/src/pages.tsx index f257ed6de800..55aecf50d97c 100644 --- a/packages/wrangler/src/pages.tsx +++ b/packages/wrangler/src/pages.tsx @@ -938,9 +938,9 @@ export const pages: BuilderCallback = (yargs) => { console.log(`Serving at http://127.0.0.1:${port}/`); if (process.env.BROWSER !== "none") { - try { - await open(`http://127.0.0.1:${port}/`); - } catch {} + const childProcess = await open(`http://127.0.0.1:${port}/`); + // fail silently if the open command doesn't work (e.g. in GitHub Codespaces) + childProcess.on("error", (_err) => {}); } if (directory !== undefined && liveReload) {