immobiliare / RealHTTP

🌀swift async http client - fast, lightweight, type-safe
MIT License
282 stars 28 forks source link

HTTPDataLoader crashes decrementStrong on line 438 #58

Closed hschouman closed 2 years ago

hschouman commented 2 years ago

Bug Report

Q A
BC Break no
Version 1.5.2

Summary

Hello, I am experiencing some crash using RealHTTP on my app. Not sure if it comes from the lib or the use I do.

Current behavior

The app crash when deallocating a pointer on line 438 of the file HTTPDataLoader.swift.

How to reproduce

2% of my users are experiencing the crash but not sure of how to reproduce for the moment.

Here are the stack trace : crash.txt

Capture d’écran 2022-07-26 à 17 45 34

Thanks for your help

malcommac commented 2 years ago

On line 438 of HTTPDataLoader on version 1.5.2 there is the following line.

Of course, we should call client's delegate to the main thread:

if let client = self.client {
  client.delegate?.client(client, didFinish: (handler.request, task), response: response)
}

However, it should be not your issue. Have you found a way to replicate this issue? Did you perform some action in your HTTPClient's delegate object for that event?

hschouman commented 2 years ago

Not found a way to replicate yet. Yes we use the delegate object for that event to forward the request.task,response.error?.error and response.data to Datadog methods : URLSessionInterceptor.shared?.taskCompleted(task: task, error: error) and URLSessionInterceptor.shared?.taskReceivedData(task: task, data: data).

Also with Xcode beta I have two warnings that are not here with Xcode 13.4.1, that could be related :

Capture d’écran 2022-08-16 à 15 10 04
malcommac commented 2 years ago

The warning should be okay with the fixes on main branch where events to delegate are sent in main thread. May you have a look and test it?

hschouman commented 2 years ago

Ok I will fetch and try the main branch on a beta with enough people to say if it fixed the crash. Thanks for your help !