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

XCode 14.3 Beta reveals hundreds of "Non-sendable" type warnings related to Apollo-generated Types #2835

Closed
mdhornet90 opened this issue Feb 20, 2023 · 8 comments
Labels

Comments

@mdhornet90
Copy link

Summary

After upgrading to the XCode 14.3 Beta, I see this sort of warning hundreds of times during compilation:

Non-sendable type 'FooQuery.Data.Foo?' passed in implicitly asynchronous call to main actor-isolated function cannot cross actor boundary

Is there anything specific to the setup I have to change to make sure these generated types conform to Sendable or is this in active development against the XCode Beta? Let me know if you need more info

Version

1.0.7

Steps to reproduce the behavior

  1. Generate GraphQL models per documentation
  2. Attempt to reference the models in an isolated async context
  3. Observe compiler warning

Logs

No response

Anything else?

No response

@mdhornet90 mdhornet90 added bug Generally incorrect behavior needs investigation labels Feb 20, 2023
@calvincestari
Copy link
Member

Hi @mdhornet90, I haven't tried the 14.3 beta and I don't think @AnthonyMDev has either.

Are you explicitly using Swift Concurrency functions or do these warnings appear even without using the new concurrency features in a project?

@mdhornet90
Copy link
Author

Generally I'm noticing these kinds of warnings in explicit async contexts. Some examples:

        await withThrowingTaskGroup(of: Void.self) { [weak self] group in
            guard let self = self else { return }

            group.addTask {
                // yields warning "Non-sendable type 'FooQuery.Data.Foo?' passed in implicitly asynchronous call to main actor-isolated function cannot cross actor boundary"
                try await self.getFoo()
            }
            ...
       }
    private func fetchUserData() async throws {
        if let userId = self.user?.id {
            // yields warning "Non-sendable type '[FooQuery.Data.Foo]' returned by call from main actor-isolated context to non-isolated instance method 'fetchFoosByUserId(userId:)' cannot cross actor boundary"
            self.multipleFoos = try await fetchFoosByUserId(userId: userId)
        }
    }

FooQuery.Data.Foo being an example of Apollo-generated types based on our GQL schema.

@calvincestari
Copy link
Member

calvincestari commented Feb 21, 2023

I've downloaded Xcode 14.3 and built both Apollo iOS and a quick sample application that uses it as a dependency but without any Swift Concurrency in it. In both builds there are no concurrency related warnings, so I think this is definitely only appearing in apps that use Xcode 14.3 + Apollo iOS + Swift Concurrency.

We've had issues before with the Sendable type which were resolved by telling the concurrency system that they're unsafe and not to apply any of the bounds checking during compilation - #2147. I'm not sure if that is what we need here too.

@AnthonyMDev
Copy link
Contributor

I think we should consider whether our generated models fulfill the requirements to be safely marked as Sendable. It seems on the surface that they do, but are there edge cases there we need to work out? The local cache mutations would likely not be Sendable as they are mutable. But immutable data should be theoretically fine to mark Sendable. I just don't want to get into a situation where we cause other people to have build errors when using them if there are edge cases where they would not be Sendable.

@kaybutter
Copy link

From the Xcode Beta Release Notes:

The Xcode “Strict Concurrency Checking” setting is not correctly passed to the compiler. If you set it to “Minimal” (the default), the compiler will still perform “Targeted” checks. (105637789)

So, these warnings are not meant to show up (because not all the features around Sendable checks have been implemented in Swift) and will probably disappear before the final 14.3 release.

@calvincestari
Copy link
Member

Note to self: Don't think we need a config option for this it should just always output the annotation but make sure it works correctly with iOS 12, which is the minimum we version we support and is a version before Swift Concurrency backport.

@calvincestari calvincestari added the planned-next Slated to be included in the next release label Mar 20, 2023
@calvincestari calvincestari self-assigned this Mar 27, 2023
@calvincestari
Copy link
Member

@mdhornet90 are the warnings still being raised in the official 14.3 GA release given @kaybutter's comments at #2835 (comment).

@calvincestari calvincestari removed the planned-next Slated to be included in the next release label May 1, 2023
@calvincestari calvincestari removed their assignment May 12, 2023
@AnthonyMDev
Copy link
Contributor

Closed due to inactivity

@AnthonyMDev AnthonyMDev closed this as not planned Won't fix, can't repro, duplicate, stale Sep 15, 2023
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

5 participants