[major]: non-Sendable parameters#5
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates JavaScriptModule to support registering asynchronous callbacks that either run on the @MainActor (allowing non-Sendable parameters) or run nonisolated (requiring Sendable parameters). Feedback was provided to ensure that the closure passed to JSClosure.async in the @MainActor registration method is explicitly isolated to @MainActor to prevent compiler warnings or errors under Swift 6 strict concurrency when handling non-Sendable parameters.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| operation: @MainActor @escaping (repeat each T) async throws -> JSValue | ||
| ) where repeat each T: LoadableFromJSValue { | ||
| self.metatype[symbol.id] = .object( | ||
| JSClosure.async { |
There was a problem hiding this comment.
Under Swift 6 strict concurrency, passing non-Sendable parameters (each T) across isolation boundaries from a nonisolated context to the @MainActor operation closure will trigger compiler warnings or errors. Since the callback is registered to run on the @MainActor, the closure passed to JSClosure.async should be explicitly isolated to @MainActor as well. This ensures that argument extraction and the subsequent call to operation occur entirely on the main actor, preventing any unsafe crossing of isolation boundaries.
JSClosure.async { @MainActor in
No description provided.