mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-05 13:09:07 +02:00
session-extend: preempt previous WaitExtendAuthSession on new wait
When the tray "Extend now" notification action and the about-to-expire
dialog both start a flow for the same deadline, the daemon was running
two independent IdP polls and the older one surfaced an InvalidArgument
toast as soon as the second RequestExtend overwrote the pending flow.
Follow the WaitSSOLogin pattern: at the top of WaitExtendAuthSession
cancel the previous wait (the SetWaitCancel/CancelWait pair on
PendingFlow already existed but was unused), then register the new
wait's cancel. Preempted callers exit with codes.Canceled; the
authsession service translates that into ExtendResult{Preempted: true}
so the tray and the React dialog can stay silent on the losing flow
instead of showing a false-failure toast / error dialog.
This commit is contained in:
+10
-2
@@ -1391,14 +1391,22 @@ func (t *Tray) runExtendSession() {
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := t.svc.Session.WaitExtend(ctx, services.ExtendWaitParams{
|
||||
result, err := t.svc.Session.WaitExtend(ctx, services.ExtendWaitParams{
|
||||
DeviceCode: start.DeviceCode,
|
||||
UserCode: start.UserCode,
|
||||
}); err != nil {
|
||||
})
|
||||
if err != nil {
|
||||
log.Warnf("session-warning: WaitExtend failed: %v", err)
|
||||
t.notifyError(t.loc.T("notify.sessionWarning.failed"))
|
||||
return
|
||||
}
|
||||
if result.Preempted {
|
||||
// Another UI surface (e.g. the about-to-expire dialog) started a
|
||||
// flow for the same deadline and took over. Stay silent so the
|
||||
// user only sees the outcome of the surviving flow.
|
||||
log.Debugf("session-warning: WaitExtend preempted by a newer flow")
|
||||
return
|
||||
}
|
||||
t.notify(t.loc.T("notify.sessionWarning.successTitle"), t.loc.T("notify.sessionWarning.successBody"), notifyIDSessionWarning)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user