pubnub / dart

PubNub Dart SDK
Other
28 stars 15 forks source link

Unsubscribe channel throws exception #58

Open mehtahardikr opened 3 years ago

mehtahardikr commented 3 years ago

sample code to replicate:

var keySet = Keyset(
      subscribeKey: 'demo',
      publishKey: 'demo', uuid: UUID('demo')
    );

var _pubnub = PubNub(networking: NetworkingModule(retryPolicy: RetryPolicy.exponential(maxRetries: 10)), defaultKeyset: keySet);

 var  _subscription = await _pubnub.subscribe(channels: {'channelA'}, withPresence: true);

_subscription?.messages?.listen((envelope) {
        debugPrint('${envelope.payload}');

      });

_subscription?.dispose();
Unhandled Exception: NoSuchMethodError: The method 'cancel' was called on null.
E/flutter (18363): Receiver: null
E/flutter (18363): Tried calling: cancel()
E/flutter (18363): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter (18363): #1      Subscription.cancel (package:pubnub/src/subscribe/subscription.dart:164:33)
E/flutter (18363): #2      Subscription.dispose (package:pubnub/src/subscribe/subscription.dart:173:29)
E/flutter (18363): #3      PubnubService.destroyPubNub (package:gr8_tables_flutter/PubnubConfig/pubnub_service.dart:151:53)
E/flutter (18363): #4      BottomSheetUtils.bottomSheetCategoryClick (package:gr8_tables_flutter/Utils/bottom_sheet_utils.dart:415:32)
E/flutter (18363): #5      BottomSheetUtils.showBottomSheet.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:gr8_tables_flutter/Utils/bottom_sheet_utils.dart:101:64)
E/flutter (18363): #6      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:991:20)
E/flutter (18363): #7      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (18363): #8      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607:11)
E/flutter (18363): #9      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:296:5)
E/flutter (18363): #10     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:267:7)
E/flutter (18363): #11     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157:27)
E/flutter (18363): #12     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:385:20)
E/flutter (18363): #13     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:361:22)
E/flutter (18363): #14     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:278:11)
E/flutter (18363): #15     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:316:7)
E/flutter (18363): #16     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:280:5)
E/flutter (18363): #17     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:238:7)
E/flutter (18363): #18     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:221:7)
E/flutter (18363): #19     _rootRunUnary (dart:async/zone.dart:1370:13)
E/flutter (18363): #20     _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (18363): #21     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (18363): #22     _invoke1 (dart:ui/hooks.dart:180:10)
E/flutter (18363): #23     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:276:7)
E/flutter (18363): #24     _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)
are commented 3 years ago

Hello, can you let me know what version of the PubNub Dart SDK are you using?

mehtahardikr commented 3 years ago

@are : its ^3.2.0

davidbrenner commented 1 year ago

Hey, @are - I am getting an exception from the cancel completer using pubnub 4.2.2. (so, a different issue than the original issue, but same general idea). This seems to be locking up my app. If it's helpful, I can create a separate ticket for this issue.