Skip to content

parity(auth): add dispose() method + AuthRefreshDiscardedError for lockless coordination [from supabase-js] #258

Open

Description

@grdsdev

SDK Parity: C# implementation needed

Reference Implementation (supabase-js)

  • Commit: 54ec2b6
  • PR: #2392
  • Module: auth
  • Type: new-feature + deprecation

What Changed

  1. New Dispose() method on auth client — explicitly stops auto-refresh and cleans up state. Implements IDisposable / IAsyncDisposable.

  2. New AuthRefreshDiscardedError — returned when a token refresh succeeded server-side but tokens were discarded because the local session changed mid-flight (e.g., concurrent SignOut).

  3. lock option deprecated — removed in v3.

Code Reference

async dispose(): Promise<void>  // stops auto-refresh

class AuthRefreshDiscardedError extends AuthError {
  name = 'AuthRefreshDiscardedError'
}

Implementation Guidance (C#)

// Implement IDisposable and/or IAsyncDisposable
public class Client : IDisposable {
    public void Dispose() {
        // Cancel refresh timer
        // Clear session
    }
}

// New exception
public class AuthRefreshDiscardedException : Exception { ... }

Acceptance Criteria

  • Dispose() / DisposeAsync() method stops auto-refresh
  • AuthRefreshDiscardedException added
  • IDisposable interface implemented

Context


Generated with Claude Code /sync-sdk-parity

Activity

  1. self-assigned this
    on Jul 1, 2026
  2. fresh55 commented on Aug 24, 2026

    @fresh55
    Contributor

    This is already broken in the client, not just missing. SignOut clears the session but a refresh that is still running puts it back at Client.cs and then PersistenceListener saves it, so the user is signed in again.

    Both RefreshToken methods do this and stopping the timer does not help because the refresh is already running. I can put a PR together in the next few days if nobody is on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions