[PR #6744] [MERGED] [client] Bring the connection up in Go after SSO login #29853

Closed
opened 2026-08-05 08:09:10 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6744
Author: @mlsmaycon
Created: 7/12/2026
Status: Merged
Merged: 7/13/2026
Merged by: @mlsmaycon

Base: mainHead: fix/gui-login-up-handoff


📝 Commits (2)

  • 0d5100e [client] Bring the connection up in Go after SSO login
  • 0e657b4 [client] unexport waitSSOLogin and move below exported methods

📊 Changes

2 files changed (+56 additions, -25 deletions)

View changed files

📝 client/ui/frontend/src/lib/connection.ts (+14 -7)
📝 client/ui/services/connection.go (+42 -18)

📄 Description

Describe your changes

Fixes the GUI client sometimes not connecting for a long time after SSO login —
until the user interacts with the app (e.g. hovering the tray icon).

Root cause: the login flow orchestrates Login → WaitSSOLogin → Up in the
frontend (client/ui/frontend/src/lib/connection.ts). WaitSSOLogin blocks in
the daemon while the user completes SSO in the external browser. During that
time the tray window is hidden and the webview is suspended (macOS App Nap /
Windows hidden-window timer throttling), so the promise continuation that
issues Up doesn't run until the webview resumes — which only happens on user
interaction. This is exactly the stall client/ui/frontend/src/lib/stallwatch.ts
was added to detect in #6717 ("the WaitSSOLogin → Up handoff"); that PR added
detection only.

Fix: move the handoff off the webview's critical path. A new Go method
Connection.WaitSSOLoginAndUp performs WaitSSOLogin and then Up entirely in
Go, so the daemon connects the moment SSO completes, independent of webview
state. The frontend calls this single method on the SSO path and no longer
issues its own Up; the non-SSO (token) path is unchanged. Cancellation still
works via the bound call's context cancel, and the method re-checks ctx.Err()
before Up. The UI catches up via the status subscription when the window
wakes.

  • client/ui/services/connection.go: add WaitSSOLoginAndUp
  • client/ui/frontend/src/lib/connection.ts: use it on the SSO path; drop the
    separate frontend Up there

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Note: this adds a UI-service method consumed only by the bundled desktop
frontend (not a public/gRPC/CLI surface). No behavior change outside the GUI
login path. Hard to cover with an automated test — it is webview-suspension
timing behind an external SSO round-trip; verified by manual repro (log in,
leave the tray window hidden, confirm the tunnel comes up without interaction).

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Internal desktop-client login fix with no user-facing configuration or API
surface.

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/__

Summary by CodeRabbit

  • New Features
    • Added a streamlined connection flow that waits for SSO authentication to complete before bringing the connection online.
    • After success, the authenticated email address is returned as part of the connection process.
  • Bug Fixes
    • Improved handling of canceled requests by ensuring interruption is detected after SSO completes.
    • Authentication and connection failures now surface as clearer, more consistent errors.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6744 **Author:** [@mlsmaycon](https://github.com/mlsmaycon) **Created:** 7/12/2026 **Status:** ✅ Merged **Merged:** 7/13/2026 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `fix/gui-login-up-handoff` --- ### 📝 Commits (2) - [`0d5100e`](https://github.com/netbirdio/netbird/commit/0d5100ef59b372e7ebc7e3366377ef44aecdfefa) [client] Bring the connection up in Go after SSO login - [`0e657b4`](https://github.com/netbirdio/netbird/commit/0e657b44d96397941b9284501821e727189d4372) [client] unexport waitSSOLogin and move below exported methods ### 📊 Changes **2 files changed** (+56 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `client/ui/frontend/src/lib/connection.ts` (+14 -7) 📝 `client/ui/services/connection.go` (+42 -18) </details> ### 📄 Description ## Describe your changes Fixes the GUI client sometimes not connecting for a long time after SSO login — until the user interacts with the app (e.g. hovering the tray icon). **Root cause:** the login flow orchestrates `Login → WaitSSOLogin → Up` in the frontend (`client/ui/frontend/src/lib/connection.ts`). `WaitSSOLogin` blocks in the daemon while the user completes SSO in the external browser. During that time the tray window is hidden and the webview is suspended (macOS App Nap / Windows hidden-window timer throttling), so the promise continuation that issues `Up` doesn't run until the webview resumes — which only happens on user interaction. This is exactly the stall `client/ui/frontend/src/lib/stallwatch.ts` was added to detect in #6717 ("the WaitSSOLogin → Up handoff"); that PR added detection only. **Fix:** move the handoff off the webview's critical path. A new Go method `Connection.WaitSSOLoginAndUp` performs `WaitSSOLogin` and then `Up` entirely in Go, so the daemon connects the moment SSO completes, independent of webview state. The frontend calls this single method on the SSO path and no longer issues its own `Up`; the non-SSO (token) path is unchanged. Cancellation still works via the bound call's context cancel, and the method re-checks `ctx.Err()` before `Up`. The UI catches up via the status subscription when the window wakes. - `client/ui/services/connection.go`: add `WaitSSOLoginAndUp` - `client/ui/frontend/src/lib/connection.ts`: use it on the SSO path; drop the separate frontend `Up` there ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). Note: this adds a UI-service method consumed only by the bundled desktop frontend (not a public/gRPC/CLI surface). No behavior change outside the GUI login path. Hard to cover with an automated test — it is webview-suspension timing behind an external SSO round-trip; verified by manual repro (log in, leave the tray window hidden, confirm the tunnel comes up without interaction). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Internal desktop-client login fix with no user-facing configuration or API surface. ### 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/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a streamlined connection flow that waits for SSO authentication to complete before bringing the connection online. * After success, the authenticated email address is returned as part of the connection process. * **Bug Fixes** * Improved handling of canceled requests by ensuring interruption is detected after SSO completes. * Authentication and connection failures now surface as clearer, more consistent errors. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:09:10 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#29853