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

Crash Thread 1: Fatal error: No data found for task 1, cannot append received data #3409

Closed
KhaledElsherbeny opened this issue Jul 11, 2024 · 6 comments
Labels

Comments

@KhaledElsherbeny
Copy link

Summary

crash occurred randomly while starting calling query

Screenshot 2024-07-11 at 4 16 18 PM

Version

1.13.0

Steps to reproduce the behavior

crash occurred randomly while starting calling query

Screenshot 2024-07-11 at 4 16 18 PM

Logs

No response

Anything else?

No response

@KhaledElsherbeny KhaledElsherbeny added bug Generally incorrect behavior needs investigation labels Jul 11, 2024
@AnthonyMDev
Copy link
Contributor

Interesting! I don't think we've ever had anyone hit this assertion failure before! It's possible there is a race condition going on here, but I would need more information in order to determine what's going on here.

Are you using a custom InterceptorProvider? I might need some more example code or a reproduction case to dig into this.

@KhaledElsherbeny
Copy link
Author

KhaledElsherbeny commented Jul 22, 2024

Thanks for your response @AnthonyMDev
We don't use any custom InterceptorProvider

func createApolloClient() -> ApolloClientProtocol {
        let configuration = URLSessionConfiguration.default
        configuration.httpAdditionalHeaders = headers

        NetworkLogger.enableLogging(for: configuration)

        let store = ApolloStore(cache: ApolloCacheContainer.shared.normalizedCache())

        let client = URLSessionClient(sessionConfiguration: configuration)
        let provider = DefaultInterceptorProvider(client: client, store: store)

        let networkTransport = RequestChainNetworkTransport(interceptorProvider: provider, endpointURL: url)
        let apolloClient = ApolloClient(networkTransport: networkTransport, store: store)

        return ApolloClientProxy(apolloClient: apolloClient)
    }

and our ApolloClientProxy class we added to perform some business needs but its simple

final class ApolloClientProxy: ApolloClientProtocol {
   var apolloClient: ApolloClient
   var store: ApolloStore

   init(apolloClient: ApolloClient) {
       self.apolloClient = apolloClient
       store = apolloClient.store
   } 
   }

please advise is there any idea to help ?

@calvincestari
Copy link
Member

@KhaledElsherbeny is this a consistent crash? Is it reproducible?

@calvincestari
Copy link
Member

calvincestari commented Jul 22, 2024

The cause of the assertion is that the internal task (TaskData) related to the URLSessionDataTask cannot be found. We use the TaskData instance to store the response, data and completion handlers for the request; I thought we should maybe send a request failure result instead of asserting but without TaskData we don't have a completion block so an assertion might be the only thing we can do here otherwise it would just fail silently.

There are a number of ways the internal task data can be removed:

  1. A call to invalidate which essentially kills the session client so this is a pretty severe action. The only place we call this method is when the DefaultInterceptorProvider is released (deinit) and that is further controllable through the shouldInvalidateClientOnDeinit property.
  2. A call to clear(task:) which is called when a task is cancelled or completes. I don't believe we ever make the call to cancel a task.
  3. A call to clearAllTasks which is called by invalidate or when 4 occurs.
  4. URLSession being invalidated through the delegate call urlSession(_:didBecomeInvalidWithError:)

I recommend checking whether you call any of those methods in your own code. Also trying to nail down the circumstances of, and how reproducible, the error is would be helpful in tracking down the root cause.

@AnthonyMDev
Copy link
Contributor

@KhaledElsherbeny were you ever able to resolve this one? We're going to need some more information on this in order to determine if there is a bug in our code and how to resolve it.

We're closing this for now due to inactivity, but we will be happy to re-open if you respond with additional information.

@AnthonyMDev AnthonyMDev closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
Copy link
Contributor

github-actions bot commented Aug 9, 2024

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants