Skip to content

Crash when using RealtimeV2 #469

@MilesV64

Description

@MilesV64

I'm facing a crash within RealtimeV2 while just leaving our app open. The app uses realtime on each screen, and when opening each screen we connect the RealtimeV2 client if needed like so:

let client = UserController.shared.supabaseClient.realtimeV2

if client.status == .disconnected {
    await client.connect()
}

// subscribe to channel etc

We never call disconnect(). However after leaving the app open, after anywhere between 5 minutes to hours the RealtimeV2 library encounters the crash Fatal error: attempt to await next() on more than one task

Frame 1
Frame 2

Seems this line for await connectionStatus in ws.connect() needs to be used very carefully. I am struggling to reproduce manually but maybe something to do with only setting status = .connecting after the Task.sleep leading to this potentially getting called twice if you were to call connect(reconnect: true) twice somehow?

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