Skip to content

Conversation

@PortoCode
Copy link
Owner

No description provided.

… blocking the main queue (tests still run synchronously in the main queue with the immediate scheduler)
… blocking the main queue (tests still run synchronously in the main queue with the immediate scheduler)
…row an error.

If the save method doesn't throw an error, the catch block is never executed, so the error assertion inside the catch block wouldn't execute. To ensure the error assertions always run, we need to move it outside the catch block.
Our Core Data store is thread-safe, so it can be safely used from any queue. However, we may want to perform store operations in a dedicated infra queue to avoid doing too much work in other queues.

For example, the URLSessionHTTPClient sends results in its URLSession delegate queue. If we store the result received from the URLSessionHTTPClient in the same queue as we receive it, we may be doing too much work in the URLSession delegate queue - which could slow down the processing of other URLSessionHTTPClient results.

To avoid this problem, we're now calling all store methods in a specific infra queue by using `receive(on: scheduler)` when performing a store operation after receiving results from another infra operation.
@PortoCode PortoCode self-assigned this Apr 1, 2025
@PortoCode PortoCode merged commit 5f608eb into main Apr 1, 2025
2 checks passed
@PortoCode PortoCode deleted the refactor/async-injection branch April 1, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants