Skip to content

AuthRetryableFetchException + HandshakeException after app resumes from long background (Flutter, supabase_flutter ^2.10.3) #1280

@vishal14321432

Description

@vishal14321432

After the app stays in the background for 6–8 hours or overnight, all Supabase requests fail with:

AuthRetryableFetchException(message: HandshakeException:
Connection terminated during handshake, statusCode: null)

This occurs even though everything works perfectly before the long background period — authentication, database reads/writes, storage, and realtime are all functioning normally.

Once this error occurs:

All Supabase operations fail (auth, postgrest, storage, realtime)

Realtime .onClose triggers but does not reconnect

The client does not recover even with retryable exceptions

Only a full app restart fixes the issue

The failure only occurs after the app resumes from a long idle state.

To Reproduce

  1. Login to the app normally (works fine).
  2. Use any Supabase functionality — all operations succeed.
  3. Put the app in the background.
  4. Leave it idle for 6+ hours (overnight).
  5. Reopen the app in the morning.
  6. Perform any Supabase operation (fetch, storage, realtime, etc.).
  7. Observe this error:

AuthRetryableFetchException(message: HandshakeException:
Connection terminated during handshake)

Image

The client does not reconnect or refresh without restarting the app.

Expected behavior

  • When the app resumes after long inactivity:
  • The Supabase client should refresh the session token (auto-refresh is enabled)
  • TLS handshake should succeed
  • Realtime should reconnect

PostgREST, Storage, and Auth requests should work normally

There should be no fatal handshake or retryable exceptions after resume.

Version

  • Flutter SDK
  • Flutter: 3.35.4 (stable)
  • Dart: 3.9.2
  • iOS: 18.6.2 (real devices)

├── supabase_flutter 2.10.3
│ ├── supabase 2.10.0
│ │ ├── functions_client 2.5.0
│ │ ├── gotrue 2.16.0
│ │ ├── postgrest 2.5.0
│ │ ├── realtime_client 2.6.0
│ │ ├── storage_client 2.4.1

supabase_flutter Initialization

await Supabase.initialize( url: dotenv.get('****'), anonKey: dotenv.get('****'), httpClient: SupabaseHttpInterceptor(http.Client()), realtimeClientOptions: RealtimeClientOptions( logLevel: RealtimeLogLevel.info, ), authOptions: const FlutterAuthClientOptions( autoRefreshToken: true, ), );

Additional context

  • This occurs on multiple real iOS devices (iPhone 11 and others)
  • Networking in the rest of the app works fine — only Supabase handshake fails
  • Seems linked to long idle + TLS session resumption + auth refresh
  • Realtime .onClose prints after resume
  • Reconnection attempts fail silently
  • No permanent fix except restarting the app

Sentry Log (redacted)

AuthRetryableFetchException(message: HandshakeException:

  • Connection terminated during handshake, statusCode: null)
  • Device: iPhone 11
  • iOS: 18.6.2
  • Architecture: arm64
  • Flutter: 3.35.4
  • Dart: 3.9.2
  • supabase_flutter: ^2.10.3
  • Environment: production

Simple Visual Explanation

App Running → Background (6–8 hrs) → Resume App

Supabase tries handshake + token refresh

❌ HandshakeException (TLS terminated)
❌ AuthRetryableFetchException
❌ Realtime disconnects & does not reconnect
❌ All PostgREST/Storage/Auth calls fail

Only fix = restart app

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions