DEV Community

Liang Wang
Liang Wang

Posted on

Non-sendable result type cannot be sent from nonisolated context in call to instance method

My class: Element

** The Problem:**
Non-sendable result type '[Element]' cannot be sent from nonisolated context in call to instance method 'fetchData(from:)'; this is an error in the Swift 6 language mode

Solution:
Mark class Element as final, and conform to protocol Sendable.

New problem:
Stored property '_id' of 'Sendable'-conforming class '...' is mutable

New Solution:
use @unchecked Sendable

Link: https://blog.vapor.codes/posts/fluent-models-and-sendable/

Top comments (0)