Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add event after closing #1016

Closed
denghejun opened this issue Aug 23, 2024 · 6 comments
Closed

Cannot add event after closing #1016

denghejun opened this issue Aug 23, 2024 · 6 comments
Labels
bug Something isn't working realtime This issue or pull request is related to realtime

Comments

@denghejun
Copy link

Bad state: Cannot add event after closing
flutter: #0 _StreamController.add (dart:async/stream_controller.dart:605)
#1 _CompleterSink.add (package:web_socket_channel/src/sink_completer.dart:90)
#2 RealtimeClient.push.callback. (package:realtime_client/src/realtime_client.dart:293)
#3 new RealtimeClient. (package:realtime_client/src/realtime_client.dart:137)
#4 RealtimeClient.push.callback (package:realtime_client/src/realtime_client.dart:293)
#5 RealtimeClient.push (package:realtime_client/src/realtime_client.dart:310)
#6 RealtimeClient.sendHeartbeat (package:realtime_client/src/realtime_client.dart:482)
#7 RealtimeClient._onConnOpen. (package:realtime_client/src/realtime_client.dart:400)
#8 _rootRunUnary (dart:async/zone.dart:1407)
#9 _CustomZone.runUnary (dart:async/zone.dart:1308)
#10 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217)
#11 _CustomZone.bindUnaryCallbackGuarded. (dart:async/zone.dar<…>
flutter: Bad state: Cannot add event after closing
flutter: #0 _StreamController.add (dart:async/stream_controller.dart:605)
#1 _CompleterSink.add (package:web_socket_channel/src/sink_completer.dart:90)
#2 RealtimeClient.push.callback. (package:realtime_client/src/realtime_client.dart:293)
#3 new RealtimeClient. (package:realtime_client/src/realtime_client.dart:137)
#4 RealtimeClient.push.callback (package:realtime_client/src/realtime_client.dart:293)
#5 RealtimeClient.push (package:realtime_client/src/realtime_client.dart:310)
#6 Push.send (package:realtime_client/src/push.dart:61)
#7 Push.resend (package:realtime_client/src/push.dart:52)
#8 RealtimeChannel.rejoin (package:realtime_client/src/realtime_channel.dart:563)
#9 RealtimeChannel.rejoinUntilConnected (package:realtime_client/src/realtime_channel.dart:189)
#10 new RealtimeChannel. (package:realtime_client/src/realtime_channel.dart:142)

@denghejun denghejun added the bug Something isn't working label Aug 23, 2024
@Vinzent03
Copy link
Collaborator

Please don't just post the error message into other issues and follow the issue template for bugs. What version are you using? What code did you use?

@denghejun
Copy link
Author

denghejun commented Aug 24, 2024

Very common code from samples:
supabase_flutter: ^2.6.0

await Supabase.initialize(
      url: AppConfig.supabaseServerUrl,
      anonKey: AppConfig.supabaseServerAnonKey,
      realtimeClientOptions: const RealtimeClientOptions(eventsPerSecond: 10),
    );

supabase = Supabase.instance.client;

channelPlayerMatch = Application.supabase.channel(
      'AGOODMAINLAND_GLOBAL_PLAYERMATCHCHANNEL',
    );

channelPlayerMatch.onBroadcast(event: NetCore.EVENT_PLAYER_LEAVE_MATCH, callback:
        (payload, [_]) {
        print('[${NetCore.EVENT_PLAYER_LEAVE_MATCH}]: received player leave match');
      }
    }).subscribe();

@denghejun
Copy link
Author

Can you rollback your code, you recently released realtime channel version cause big issue for my app. players can not see all other's position in game.

@denghejun
Copy link
Author

denghejun commented Aug 25, 2024

I found the actual issue is the subscribe((status,error){
print(status);
}) the status sometimes always return: RealtimeSubscribeStatus.timedOut, and after a while, the status became to "RealtimeSubscribeStatus.closed", and then never came back again, it will show the issue like "Bad state: Cannot add event after closing
"

@dshukertjr dshukertjr added the realtime This issue or pull request is related to realtime label Aug 26, 2024
@Vinzent03
Copy link
Collaborator

With #1019 being merged now, this issue should hopefully be solved now. You can try it by upgrading supabase_flutter to 2.7.0. If you still experience any issues, please create a new issue.

@denghejun
Copy link
Author

Got RealtimeSubscribeStatus.timedOut sometime, from China. The situation is sometime I got subscribed , sometimes I got timeout. Is the realtime API blocked from China? any workaround to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working realtime This issue or pull request is related to realtime
Projects
None yet
Development

No branches or pull requests

3 participants