From db97ef7c8df5feaac4112d8990c9dbf9498e2746 Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Wed, 11 Nov 2026 18:22:53 +0100 Subject: [PATCH] protondrive: stop a call rejected during disconnect retrying without credentials A call in flight when the remote was disconnected, and then rejected as unauthorised, was sent again with empty credentials. It now fails with the "not signed in" error instead. Co-Authored-By: Claude Opus 5.5 --- backend/protondrive/session.go | 4 ++++ backend/protondrive/session_internal_test.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/backend/protondrive/session.go b/backend/protondrive/session.go index 330218ba1..4c94ffb1f 100644 --- a/backend/protondrive/session.go +++ b/backend/protondrive/session.go @@ -224,6 +224,10 @@ func (s *session) call(ctx context.Context, opts *rest.Opts, request, response a } } creds = s.current() + if creds.UID == "" { + // Signed out while the call was made. + return resp, s.signInNeeded(errNotSignedIn) + } return s.do(ctx, opts, request, response, &creds) } diff --git a/backend/protondrive/session_internal_test.go b/backend/protondrive/session_internal_test.go index ca258ea2d..3bdd0938d 100644 --- a/backend/protondrive/session_internal_test.go +++ b/backend/protondrive/session_internal_test.go @@ -526,3 +526,21 @@ func TestLogout(t *testing.T) { old.adoptWait = 0 assert.ErrorIs(t, authCall(context.Background(), old), errSessionExpired) } + +func TestCallDuringLogout(t *testing.T) { + t.Parallel() + ctx := context.Background() + srv := protontest.New(t) + s, _, _ := newTestSession(t, srv) + // The call is rejected only after the session has signed out. + srv.Inject(protontest.Fault{Method: "GET", Pattern: "/tests/auth", Times: 1, Status: http.StatusUnauthorized, Delay: 500 * time.Millisecond}) + errc := make(chan error, 1) + go func() { errc <- authCall(ctx, s) }() + require.Eventually(t, func() bool { return srv.Requests()["GET /tests/auth"] == 1 }, 5*time.Second, 5*time.Millisecond) + require.NoError(t, s.logout(ctx)) + + err := <-errc + assert.ErrorIs(t, err, errNotSignedIn) + assert.Equal(t, 1, srv.Requests()["GET /tests/auth"], "retried without credentials") + assert.Zero(t, srv.Requests()[refreshRoute]) +}