Skip to content

Commit

Permalink
Fix silent failure when browser open doesn't work (#263)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
jkriss and threepointone authored Jan 18, 2022
1 parent 2a89ee5 commit 402c77d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-lemons-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

fix: appropriately fail silently when the open browser command doesn't work
6 changes: 3 additions & 3 deletions packages/wrangler/src/pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -938,9 +938,9 @@ export const pages: BuilderCallback<unknown, unknown> = (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) {
Expand Down

0 comments on commit 402c77d

Please sign in to comment.