launchdarkly / ios-client-sdk

LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
https://docs.launchdarkly.com/sdk/client-side/ios
Other
70 stars 84 forks source link

Error: Task created in a session that has been invalidated #262

Closed ugiacoman closed 2 years ago

ugiacoman commented 2 years ago

Describe the bug We've gotten crash reports with the following error:

Task created in a session that has been invalidated

To reproduce We haven't tried reproducing on our end, but we've seen over 135 crashes from our users. LDSwiftEventSource seems to be invalidating requests by calling invalidateAndCancel().

Expected behavior Our app not to crash 😅 .

Logs Cannot provide any logs.

SDK version 3.4.4

Language version, developer tools n/a

OS/platform This is only affecting our iOS 15 users.

Additional context We released a new build with the only change being an upgrade of the LD SDK to 3.4.4. We saw an increase in errors unrelated to this one, but coming from the LD SDK, so we downgraded and submitted a new build. This crash only occurs on the build where we upgraded the LD SDK to 3.4.4. This leads us to strongly believe that this is an issue originating from the LD SDK.

louis-launchdarkly commented 2 years ago

Hello @ugiacoman, thank you for reporting the issue - between this one and https://github.com/launchdarkly/ios-client-sdk/issues/261, there could be something wrong with the event source. We will need to investigate more and get back to you. Also, we may need to ask you for more information during the investigation, so we will comment on this issue again.

simonliotier commented 2 years ago

Hello,

We've also received many crash reports after we've upgraded to v5.4.4. Here is the stack trace provided by Crashlytics:

Fatal Exception: NSGenericException
Task created in a session that has been invalidated
Fatal Exception: NSGenericException
0  CoreFoundation                 0x990fc __exceptionPreprocess
1  libobjc.A.dylib                0x15d64 objc_exception_throw
2  CFNetwork                      0x28b30 CFURLRequestSetRequestPriority
3  LDSwiftEventSource             0x8ae4 EventSourceDelegate.connect() + 191 (LDSwiftEventSource.swift:191)
4  LDSwiftEventSource             0x84a8 closure #1 in EventSourceDelegate.start() + 151 (LDSwiftEventSource.swift:151)
5  LDSwiftEventSource             0x8514 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
6  libdispatch.dylib              0x2924 _dispatch_call_block_and_release
7  libdispatch.dylib              0x4670 _dispatch_client_callout
8  libdispatch.dylib              0xbdf4 _dispatch_lane_serial_drain
9  libdispatch.dylib              0xc968 _dispatch_lane_invoke
10 libdispatch.dylib              0x171b8 _dispatch_workloop_worker_thread
11 libsystem_pthread.dylib        0x10f4 _pthread_wqthread
12 libsystem_pthread.dylib        0xe94 start_wqthread
gwhelanLD commented 2 years ago

Hi @ugiacoman, @simonliotier,

We believe this should be resolved in the 5.4.5 release. Please give it a try, if it doesn't resolve these crashes feel free to reopen the GH issue.

Thanks, @gwhelanLD