Skip to content

Realtime not reconnecting after going offline and refreshing app in Expo #463

Open
@jmeistrich

Description

@jmeistrich

Bug report

  • [ x ] I confirm this is a bug with Supabase, not with my own application.
  • [ x ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

In an Expo app in development mode with an iOS simulator, going offline and back online and then reloading the app results in realtime being stuck in errors even through reloads until the app is force quit.

This may be in development-only, but not sure because it blocked releasing to production. We've had multiple reports of a bug in Legend State (LegendApp/legend-state#362) which track back to this root problem.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

This was reproduced by multiple people starting from the Expo with-legend-state-supabase example, but it may happen in any Expo project.

Add this code to log the error:

supabase
    .channel(`LS_TEST`)
    .on(
        'postgres_changes',
        {
            event: '*',
            table: 'todos',
            schema: 'public',
        },
        (payload) => {
            console.log('payload', payload);
        },
    )
    .subscribe((status, error) => {
        console.log('status', status);
        console.log('error', error);
    });
  1. Quit app if already open
  2. Open app, realtime connects
  3. Go offline and back online
  4. Reload app in dev tools
  5. Realtime errors forever even with more reloads, until app is fully restarted with this log:
status CHANNEL_ERROR
error undefined

Expected behavior

Realtime should work after reload

System information

  • OS: macOS
  • Browser (if applies): Expo with iOS simulator
  • Version of supabase-js: 2.45.1
  • Version of Node.js:20

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions