Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't crash when browser windows don't open #415

Merged
merged 1 commit into from
Feb 9, 2022
Merged

Conversation

threepointone
Copy link
Contributor

We open browser windows for a few things; during wrangler dev, and logging in. There are environments where this doesn't work as expected (like codespaces, stackblitz, etc). This fix simply logs an error instead of breaking the flow. This is the same fix as #263, now applied to the rest of wrangler.

@changeset-bot
Copy link

changeset-bot bot commented Feb 8, 2022

🦋 Changeset detected

Latest commit: 0261979

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2022

wrangler prerelease is available for testing:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/1817914398/wrangler

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just move this into a helper function? It would help keep the call-sites cleaner and would also encourage others to do the right thing when they need to open a thingy.
It also would help, later, when writing tests, since it would be easier to mock out.

@JacobMGEvans
Copy link
Contributor

Could we just move this into a helper function? It would help keep the call-sites cleaner and would also encourage others to do the right thing when they need to open a thingy. It also would help, later, when writing tests, since it would be easier to mock out.

Would be only one place for a Sentry capture as well and cover way more ground.

@threepointone
Copy link
Contributor Author

Sorry if I'm missing something, but I don't think this is related to sentry? Do we suppose we'll want to capture failures to open these windows? I'd think not. It usually means that they're using wrangler inside something like codespaces, where the failure is expected, we just don't want the process to crash.

We open browser windows for a few things; during `wrangler dev`, and logging in. There are environments where this doesn't work as expected (like codespaces, stackblitz, etc). This fix simply logs an error instead of breaking the flow. This is the same fix as #263, now applied to the rest of wrangler.
const childProcess = await open(`http://localhost:${port}/`);
// fail silently if the open command doesn't work (e.g. in GitHub Codespaces)
childProcess.on("error", (_err) => {});
await openInBrowser(`http://localhost:${port}/`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GregBrimble ^ I also replaced pages' usage of open(), fyi.

@threepointone threepointone merged commit d826f5a into main Feb 9, 2022
@threepointone threepointone deleted the fix-url-open branch February 9, 2022 12:11
@github-actions github-actions bot mentioned this pull request Feb 9, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Feb 9, 2022

Hey @threepointone, there's a typo in the packages/wrangler/src/open-in-brower.ts filename 😉

@threepointone
Copy link
Contributor Author

lol dammit, thanks @mrbbot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants