Crash in save<Models> from DataStoreBaseBehavior
Describe the bug
Hi Team, Today I got crash while running the ios app. The crash was in extension class DataStoreBaseBehavior-
func save<M: Model>(_ models: [M], where predicate: QueryPredicate?) async throws -> [M] { let results = try await withThrowingTaskGroup(of: M.self) { group in for model in models { group.addTask { try await save(model, where: predicate) // Crash line } }
return try await group.reduce(into: []) { array, model in
array.append(model)
}
}
return results
}
Steps To Reproduce
I got it on app launch.
Crash error -
Thread 94: Fatal error: SWIFT TASK CONTINUATION MISUSE: save(_:modelSchema:where:) tried to resume its continuation more than once, throwing DataStoreError: The operation couldn’t be completed. (SQLite.Result error 0.)
Recovery suggestion: The operation couldn’t be completed. (SQLite.Result error 0.)
Caused by:
cannot rollback - no transaction is active (code: 1)!
Expected behavior
App should not crash in save models
Amplify Framework Version
2.33.6
Amplify Categories
DataStore
Dependency manager
Swift PM
Swift version
5.9.2
CLI version
12.11.1
Xcode version
15.2
Relevant log output
Thread 94: Fatal error: SWIFT TASK CONTINUATION MISUSE: save(_:modelSchema:where:) tried to resume its continuation more than once, throwing DataStoreError: The operation couldn’t be completed. (SQLite.Result error 0.)
Recovery suggestion: The operation couldn’t be completed. (SQLite.Result error 0.)
Caused by:
cannot rollback - no transaction is active (code: 1)!
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
iOS 17.5
Device
iPhone 15 Plus
Specific to simulators
No response
Additional context
No response
@amruth-movano Thanks for submitting your issue. To help reduce produce the issue, can you provide your model/schema and the request parameters that resulted in the crash?
@phantumcode Hi, currently it is not reproducible, so not sure how can I help wth parameters which were resulted in crash
@amruth-movano Are you able to provide your model schema or a example schema or test app that can help reproduce the issue?
@phantumcode I am not getting it while debugging, its from firebase now. Below is the crash logs -
Crashed: com.apple.root.user-initiated-qos.cooperative
0 libswiftCore.dylib 0x38870 assertionFailure(::file:line:flags:) + 264
1 libswift_Concurrency.dylib 0x5b80 CheckedContinuation.resume(throwing:) + 472
2 Evie Ring 0x85ea88 CheckedContinuation.resume<A>(with:) + 4348406408 (
We addressed a similar issue in #3595, with the patch released in version 2.29.1. We'll investigate this further, but could you also double confirm the version associated with the crash log?