-
Notifications
You must be signed in to change notification settings - Fork 199
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 when saving data using datastore #3595
Comments
Hi @amruth-movano , thanks for opening this issue. We will try to reproduce and post any updates here. To help us root cause, could you please enable verbose logging by adding If you can add some code snippets on how you're using the API, that's also helpful. Thanks! |
@ruisebas please see the attached file with verbose output. |
@ruisebas , We are saving the data directly to dynamodb using datastore. public final class SampleDataStore: SampleDataStorable {
private let dataStore: DataStoreBaseBehavior
private var userId: GetUserId
init(dataStore: DataStoreBaseBehavior, userId: @escaping GetUserId) {
self.dataStore = dataStore
self.userId = userId
}
public convenience init() {
self.init(
dataStore: Amplify.DataStore,
userId: { try await Amplify.Auth.getCurrentUser().userId }
)
}
public func saveSampleData(_ value: DataStore.SampleData) async throws {
let userId = try await userId()
let telemetry = SampleDataMapper.map(value, userId: userId)
_ = try await dataStore.save(telemetry, where: nil)
}
} |
Hi @amruth-movano, thank for all the information. I was able to reproduce the crash and I'm working on a fix for it. However, please note that setting a predicate condition on a create operation (i.e. calling |
The DataStore feature is designed to enable data accessibility even when the device is not connected to the internet or has limited connectivity. When you create model instances using
|
The fix for multiple withCheckedContinuation invocations is released in v2.29.1. This issue is closed for now, but feel free to reopen it if the problem persists. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
We are saving data to data store with predicate. I am getting crash when predicate is not nil. But when predicate set to nil, everything works fine.
Fatal error: SWIFT TASK CONTINUATION MISUSE: save(_:modelSchema:where:) tried to resume its continuation more than once, throwing DataStoreError: Cannot apply a condition on model which does not exist.
Recovery suggestion: Save the model instance without a condition first.!
But we want to add predicate for all the queries
Steps To Reproduce
Expected behavior
App should save data to dynamodb
Amplify Framework Version
2.28.0
Amplify Categories
DataStore
Dependency manager
Swift PM
Swift version
5.0
CLI version
NA
Xcode version
15.2
Relevant log output
Fatal error: SWIFT TASK CONTINUATION MISUSE: save(_:modelSchema:where:) tried to resume its continuation more than once, throwing DataStoreError: Cannot apply a condition on model which does not exist. Recovery suggestion: Save the model instance without a condition first.!
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
iOS 17.4
Device
iPhone 15 Plus
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: