Skip to content
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

test(sync) Add tests to run fetchSaves and fetchArchive at the same t… #710

Merged
merged 1 commit into from
May 5, 2023

Conversation

CMasterson
Copy link
Contributor

@CMasterson CMasterson commented May 5, 2023

…ime on 2 threads. Fix crash in mockOperationFactory

Summary

When in the background the app may try to fetch saves and archive at the same time, from 2 different threads with can cause a crash.
@bassrock guided me through adding childContexts for those operations which fixes the crash.

References

https://pocket.sentry.io/issues/4156754439/events/9e85fa2a05f34a739fbd45c63a5ced53/
https://pocket.sentry.io/issues/4156756592/events/83a8ff1dddad4e4e8805329aa7049c80/

Implementation Details

Added a childContext in the PocketSource enqueue function to avoid collisions between threads.
Also, to fix a crash in MockOperationFactory, we wrapped the fetchArchiveCall assignment in a DispatchQueue .sync

Test Steps

The crash happens in the background, so testing seems nigh-impossible.

PR Checklist:

  • Added Unit / UI tests
  • Self Review (review, clean up, documentation, run tests)
  • Basic Self QA

…ime on 2 threads. Fix crash in mockOperationFactory
@CMasterson CMasterson requested a review from a team as a code owner May 5, 2023 16:44
@CMasterson CMasterson requested review from dskuza and nzeltzer and removed request for a team May 5, 2023 16:44
@CMasterson CMasterson enabled auto-merge (squash) May 5, 2023 16:56
@CMasterson CMasterson merged commit 8f8b746 into develop May 5, 2023
@CMasterson CMasterson deleted the background_task_crash branch May 5, 2023 16:57
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