-
-
Notifications
You must be signed in to change notification settings - Fork 876
[client] Close Re-Auth Window If Client Is Already Connected #4525
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
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the re-authentication UI flow so that the login prompt automatically closes when the client is already connected.
- showLoginURL now returns a CancelFunc and spins up a background goroutine to poll connection status.
- The login window registers an OnClosed handler to cancel the goroutine.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
case <-ctx.Done(): | ||
return | ||
case <-ticker.C: | ||
status, err := conn.Status(s.ctx, &proto.StatusRequest{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Status RPC uses s.ctx instead of the cancellable ctx created for this goroutine, meaning in-flight calls won’t be canceled when cancel() is invoked or when the window closes. Use ctx so the RPC respects cancellation.
status, err := conn.Status(s.ctx, &proto.StatusRequest{}) | |
status, err := conn.Status(ctx, &proto.StatusRequest{}) |
Copilot uses AI. Check for mistakes.
conn, err := s.getSrvClient(failFastTimeout) | ||
if err != nil { | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If acquiring the service client fails once, the goroutine exits and the auto-close behavior never runs. This makes the feature inert under transient startup/network conditions. Consider retrying acquisition inside the loop (or continuing until ctx.Done()) so it recovers from transient failures.
conn, err := s.getSrvClient(failFastTimeout) | |
if err != nil { | |
return | |
var conn proto.ClientServiceClient | |
for { | |
select { | |
case <-ctx.Done(): | |
return | |
default: | |
} | |
var err error | |
conn, err = s.getSrvClient(failFastTimeout) | |
if err != nil { | |
// Retry after a short delay if acquiring the client fails | |
time.Sleep(2 * time.Second) | |
continue | |
} | |
break |
Copilot uses AI. Check for mistakes.
[client] Close Re-Auth Window If Client Is Already Connected
Describe your changes
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__