Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Make ngrok errors more robust and helpful #1874

Merged
merged 5 commits into from
Mar 22, 2022

Conversation

amcaplan
Copy link
Contributor

WHY are these changes introduced?

We see many ngrok errors in bugsnag. This will make it easier to
understand what's happening and take action.

WHAT is this pull request doing?

Catching errors frequently observed in bugsnag and giving more helpful feedback.

How to test your changes?

For the dual tunnel issue, I think you might need to have 2 ngrok sessions on 2 different machines. Docker might help here.

Post-release steps

Update checklist

  • I've added a CHANGELOG entry for this PR (if the change is public-facing)
  • I've considered possible cross-platform impacts (Mac, Linux, Windows).
  • I've left the version number as is (we'll handle incrementing this when releasing).
  • I've included any post-release steps in the section above.

@amcaplan
Copy link
Contributor Author

For the incorrect auth token issue, here's with and without the change, for app and extension:

Screen Shot 2021-12-22 at 10 51 30

Screen Shot 2021-12-22 at 10 51 38

For the double-tunnel issue, I got ngrok running in a VM, and then tried these commands on my local machine, with and without the change, for app and extension.

Screen Shot 2021-12-22 at 10 30 56

Screen Shot 2021-12-22 at 10 31 08

Copy link
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

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

Regardless the messages, the approach LGTM!

@@ -115,6 +115,8 @@ module Messages
tunnel_already_running: "A tunnel running on another port has been detected. Close the tunnel and try again.",
},
tunnel: {
duplicate_session: "Another ngrok tunnel is currently running with your auth token, possibly on another machine. You must terminate that tunnel before opening a new one.\nAdditional information from ngrok logs: %s",
invalid_token: "The ngrok token you configured has expired. After generating a new token, you can update your local ngrok configuration using `shopify app tunnel auth <token>`\nAdditional information from ngrok logs: %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure the token can expire? I can't find anything on the docs about that: https://ngrok.com/docs#getting-started-authtoken

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I think you can only rotate it manually. So perhaps something like, "The ngrok token you configured has been invalidated."

@@ -178,6 +178,14 @@ def install(ctx)

def fetch_url(ctx, log_path)
LogParser.new(log_path)
rescue NgrokError => e
case e.message
when /\AYour account is limited to 1 simultaneous ngrok client session/
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be awesome if Ngrok used status codes when exiting their process unsuccessfully. I created this issue to keep track of these things to share feedback with them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pepicrft I think they actually do use error codes. Sounds like I should edit this to look for the error code rather than the text, and maybe link to that doc in a comment here.

@MeredithCastile
Copy link
Contributor

@amcaplan and I chatted today and I offered the principle of eliminating "You must" from error messages. So the string would be "Stop running the tunnel" or "Terminate the tunnel" rather than "You must terminate..."

We also chatted about removing the logs so as not to expose the token if someone were to create a GitHub issue.

@github-actions
Copy link

This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.

→ If there's no activity within a week, then a bot will automatically close this.

Thanks for helping to improve Shopify's dev tooling and experience.

We see many ngrok errors in bugsnag. This will make it easier to
understand what's happening and take action.
* Don't print logs which may include sensitive information
* The token is invalid, not expired. ngrok tokens don't expire.
* No "you"
@amcaplan amcaplan changed the title Make ngrok errors more robust and helpful. Make ngrok errors more robust and helpful Mar 22, 2022
@amcaplan amcaplan force-pushed the gentler-ngrok-dual-tunnel-error-handling branch from 68242af to de0a40d Compare March 22, 2022 11:09
@amcaplan amcaplan marked this pull request as ready for review March 22, 2022 11:09
@amcaplan amcaplan requested review from a team, jesalerno84 and molly-yu and removed request for a team March 22, 2022 11:09
@amcaplan
Copy link
Contributor Author

Hehe, forgot about this until the stale bot reminder. Updated and ready to merge!

@amcaplan amcaplan force-pushed the gentler-ngrok-dual-tunnel-error-handling branch from 08c94da to 4e84cec Compare March 22, 2022 12:48
@amcaplan amcaplan merged commit 4bd1f88 into main Mar 22, 2022
@amcaplan amcaplan deleted the gentler-ngrok-dual-tunnel-error-handling branch March 22, 2022 13:14
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems March 24, 2022 11:32 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants