pubnub / dart

PubNub Dart SDK
Other
27 stars 15 forks source link

Getting error while calling dispose() or cancel() on subscription #114

Open mehtahardikr opened 1 year ago

mehtahardikr commented 1 year ago
var pubnub = PubNub(
  defaultKeyset:
      Keyset(subscribeKey: 'mySubscribeKey', publishKey: 'myPublishKey', uuid: UUID('uuid')));

var channel = "sample_channel";
var subscription = pubnub.subscribe(channels: {channel});

subscription.cancel(); or await subscription.cancel(); or await subscription.dispose();

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Future already completed
                                                                                                    #0      _AsyncCompleter.complete (dart:async/future_impl.dart:35:31)
                                                                                                    #1      Subscription.cancel (package:pubnub/src/subscribe/subscription.dart:176:22)
                                                                                                    <asynchronous suspension>
mohitpubnub commented 1 year ago

Is it reproducible by the snippet you have shared? By running that code with my keyset I'm not seeing reported error. However, I see that it's guarded operation by checking completion of mentioned promise.