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 in GraphQLQueryWatcher.cancel() and GraphQLQueryWatcher.refetch() #3476

Closed
damian0815 opened this issue Nov 20, 2024 · 7 comments
Closed
Labels
bug Generally incorrect behavior needs investigation

Comments

@damian0815
Copy link
Contributor

damian0815 commented Nov 20, 2024

Summary

When I attempt to call refetch() or cancel() on a GraphQLQueryWatcher i get an EXC_BAD_ACCESS.

  • with refetch() it's in GraphQLQueryWatcher.fetch() on the first line ($fetching.mutate {).
    image
  • with cancel() it's on the first line of the cancel() func fetching.cancellable?.cancel()

Version

1.15.1

Steps to reproduce the behavior

refetch() is being called from the main thread of my app. I have verified that I'm also creating the GraphQLQueryWatcher on the main thread. I've also tried using refetch() in a detached Task (Task.detached), which doesn't help either.

Logs

Backtrace:

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x0000000000000000 in 0x00000000 ()
#1	0x0000000104971580 in GraphQLQueryWatcher.fetch(cachePolicy:) at /Users/damian/Library/Developer/Xcode/DerivedData/XXXX-boiyzzgkimuasqfevhtzbuipxoth/SourcePackages/checkouts/apollo-ios/Sources/Apollo/GraphQLQueryWatcher.swift:72
#2	0x00000001049714dc in GraphQLQueryWatcher.refetch(cachePolicy:) at /Users/damian/Library/Developer/Xcode/DerivedData/XXXX-boiyzzgkimuasqfevhtzbuipxoth/SourcePackages/checkouts/apollo-ios/Sources/Apollo/GraphQLQueryWatcher.swift:68

Anything else?

No response

@damian0815
Copy link
Contributor Author

Updated - also hitting on .cancel()

@damian0815 damian0815 changed the title Crash in GraphQLQueryWatcher.refetch() Crash in GraphQLQueryWatcher.cancel() and GraphQLQueryWatcher.refetch() Nov 20, 2024
@calvincestari
Copy link
Member

I was going to ask if you're able to reproduce this in a standalone project that we can debug because we have tests that use both those methods without error.

But..based on your other comment I wonder if this crash is because of how you're manipulating the cache by deleting the object but not updating the lists that reference that object. So the subsequent fetch is looking for a cache object that isn't there.

Why it's crashing on cancel though I'm not sure. 🤔

@damian0815
Copy link
Contributor Author

But..based on #3472 (comment) I wonder if this crash is because of how you're manipulating the cache by deleting the object

ahh, that's a good thought but it was crashing before I added that.

@damian0815
Copy link
Contributor Author

also seeing the issue on v1.15.3. in case it's relevant I am on Xcode 15.4, macOS 14.5, building against Swift 5, targetting macOS 13.1

@calvincestari
Copy link
Member

ahh, that's a good thought but it was crashing before I added that.

What happens if you call refetch() with a policy to ignore the cache? Trying to eliminate the cache as a potential factor here.

also seeing the issue on v1.15.3. in case it's relevant I am on Xcode 15.4, macOS 14.5, building against Swift 5, targetting macOS 13.1

We run our unit tests on both Xcode 15.4 and Xcode 16.1 so the tests I referenced earlier are being run on the same platform as you. Shouldn't really matter though.

@damian0815
Copy link
Contributor Author

I tracked the problem down, it was due to us linking against Apollo libs twice (once in our networking framework and once in the app). Please feel free to close this issue.

@calvincestari calvincestari closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2024
Copy link
Contributor

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
bug Generally incorrect behavior needs investigation
Projects
None yet
Development

No branches or pull requests

2 participants