Repository navigation
webhook: fail fast without an ngrok authtoken, report connection failures, bound the connect - #108
Open
sunilmehta-si wants to merge 1 commit into
Open
sunilmehta-si wants to merge 1 commit into
sunilmehta-si wants to merge 1 commit into
Conversation
…ures, bound the connect A blank prompt with NGROK_AUTHTOKEN unset went to ngrok.WithAuthtokenFromEnv() with an empty token. The SDK treats the authentication failure as temporary and retries it forever, so `xurl webhook start` sat in connection setup with no tunnel URL and no error until it was killed. - Resolve the token up front (prompt, then NGROK_AUTHTOKEN) and exit 1 with a message that says how to supply one when there is none. - Print each connection failure through ngrok.WithDisconnectHandler, so an invalid token shows its ERR_NGROK_105 instead of nothing. - Add --connect-timeout (default 30s): the context is cancelled if the tunnel is not up in time, which makes ngrok.Listen return an error naming the last failure. The timer stops once the tunnel is up, so reconnects are unaffected. Fixes xdevplatform#107
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #107.
xurl webhook startaccepted a blank authtoken prompt withNGROK_AUTHTOKENunset, passed an empty token to the ngrok SDK, and then sat in connection setup with no tunnel URL and no error. The SDK treats the authentication failure as temporary and retries it forever, so a failed start was indistinguishable from a slow one until the process was killed.Three changes in
cli/webhook.go:NGROK_AUTHTOKEN. With neither, the command exits 1 withno ngrok authtoken: enter one at the prompt or set NGROK_AUTHTOKEN (get it from https://dashboard.ngrok.com/get-started/your-authtoken).ngrok.WithDisconnectHandler, so an invalid token shows itsERR_NGROK_105message instead of nothing.--connect-timeout(default 30s) cancels the connect context if the tunnel is not up in time, songrok.Listenreturns an error that names the last failure. The timer is stopped once the tunnel is up, so the session's own reconnects later on are unaffected.resolveNgrokAuthtokenis a small pure function with a table test (cli/webhook_test.go); the webhook command had no tests before. CHANGELOG has an entry under Unreleased.Verification
Ran the reproduction script from #107 (fresh
HOME, synthetic OAuth 1.0a credentials, blank line to the prompt, noNGROK_AUTHTOKEN):mainat 18dcb44: still running after 30 s, last lineConfiguring ngrok to forward to local port: 8080.--connect-timeout 6s: printsngrok: authentication failed: The authtoken you specified does not look like a proper ngrok authtoken ... ERR_NGROK_105on each attempt, thenError starting ngrok tunnel: not connected after 6s; the last error was: ...and exits 1.gofmt -l .clean,go vet ./...clean,go test ./...passes (Go 1.27.3, darwin/arm64). Not tested with a valid ngrok token (I don't have an ngrok account); the success path only differs in that the timer is stopped afterListenreturns.