perform(sync:) getting stuck #360

Closed
opened 2025-12-29 15:29:59 +01:00 by adam · 4 comments
Owner

Originally created by @TheJustikar on GitHub (Feb 17, 2021).

Hi,

I am using this block to clear my data before adding my test data for unit and ui tests:

extension DataStack {
    func addTestData() {
        clearCurrentData()
        //add test data ...
    }

    func clearCurrentData() {
        do {
            try perform { transaction in
                try transaction.deleteAll(From<Class1>())
                try transaction.deleteAll(From<Class2>())
                try transaction.deleteAll(From<Class3>())
                //...
            }
        } catch {
            fatalError(error.localizedDescription)
        }
    }
}

This gets called in the setUp() method of 2 of my unit tests. The 1. one work fine, but the second one just gets stuck without an error, but the tests don't start.

Am I doing anything wrong?

Originally created by @TheJustikar on GitHub (Feb 17, 2021). Hi, I am using this block to clear my data before adding my test data for unit and ui tests: ``` extension DataStack { func addTestData() { clearCurrentData() //add test data ... } func clearCurrentData() { do { try perform { transaction in try transaction.deleteAll(From<Class1>()) try transaction.deleteAll(From<Class2>()) try transaction.deleteAll(From<Class3>()) //... } } catch { fatalError(error.localizedDescription) } } } ``` This gets called in the `setUp()` method of 2 of my unit tests. The 1. one work fine, but the second one just gets stuck without an error, but the tests don't start. Am I doing anything wrong?
adam closed this issue 2025-12-29 15:30:00 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Feb 18, 2021):

Do you have your Unit Test project running in parallel?
image

@JohnEstropia commented on GitHub (Feb 18, 2021): Do you have your Unit Test project running in parallel? ![image](https://user-images.githubusercontent.com/3029684/108282206-868f5080-71c4-11eb-8d55-303efe6627e8.jpeg)
Author
Owner

@TheJustikar commented on GitHub (Feb 19, 2021):

No

@TheJustikar commented on GitHub (Feb 19, 2021): No
Author
Owner

@JohnEstropia commented on GitHub (Feb 19, 2021):

If so then it's likely you are mixing sync and async transactions. Make sure you don't have unfinished async transactions when running sync ones. You can inspect the stack trace when you hit a deadlock, that should show you which other transaction it's waiting for.

@JohnEstropia commented on GitHub (Feb 19, 2021): If so then it's likely you are mixing sync and async transactions. Make sure you don't have unfinished async transactions when running sync ones. You can inspect the stack trace when you hit a deadlock, that should show you which other transaction it's waiting for.
Author
Owner

@TheJustikar commented on GitHub (Feb 19, 2021):

Thanks, yeah I missed some async-transactions in one of the tests and waiting for the fixed it

@TheJustikar commented on GitHub (Feb 19, 2021): Thanks, yeah I missed some async-transactions in one of the tests and waiting for the fixed it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#360