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

Fix data race for subscribers property #599

Merged

Conversation

tahirmt
Copy link
Contributor

@tahirmt tahirmt commented Feb 4, 2025

Fixes apollographql/apollo-ios#3512

This data race can happen if is a start/stop subscription at the same time as a message received on the websocket getting processed. The subscribers property is accessed from two threads at the same time causing a crash.

I am not really sure how I can add unit tests for this change. The data race type tests are really hard to write.

Copy link

netlify bot commented Feb 4, 2025

👷 Deploy request for apollo-ios-docc pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 2f48cfa

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Feb 4, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 14 changed, 0 removed
* (developer-tools)/ios/(latest)/tutorial/tutorial-add-graphql-schema.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-add-more-info-to-list.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-authenticate-operations.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-complete-details-view.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-configure-project.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-connect-queries-to-ui.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-define-additional-mutations.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-execute-first-query.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-first-mutation.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-introduction.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-paginate-results.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-running-code-generation.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-subscriptions.mdx
* (developer-tools)/ios/(latest)/tutorial/tutorial-write-your-first-query.mdx

Build ID: e09f794785939e4e7bc17390

URL: https://www.apollographql.com/docs/deploy-preview/e09f794785939e4e7bc17390

@BobaFetters
Copy link
Member

Thanks for putting up a PR for this fix! Is there more work you are planning for this PR since its in a draft state still?

@tahirmt
Copy link
Contributor Author

tahirmt commented Feb 4, 2025

@BobaFetters no I just left it in draft because I wasn't sure of the feedback I would get regarding unit tests.

@tahirmt tahirmt marked this pull request as ready for review February 4, 2025 19:35
@BobaFetters
Copy link
Member

@tahirmt Gotcha, yea like you said this type of data race is hard to really write a test for so I don't think thats necessary here

@BobaFetters BobaFetters merged commit 2446895 into apollographql:main Feb 4, 2025
25 checks passed
BobaFetters pushed a commit that referenced this pull request Feb 4, 2025
BobaFetters pushed a commit to apollographql/apollo-ios that referenced this pull request Feb 4, 2025
BobaFetters pushed a commit that referenced this pull request Feb 4, 2025
720622da Fix data race for subscribers property (#599)

git-subtree-dir: apollo-ios
git-subtree-split: 720622da5451f3dc08fb2b90a7b060bfc4f4c6ed
BobaFetters pushed a commit that referenced this pull request Feb 4, 2025
git-subtree-dir: apollo-ios
git-subtree-mainline: 872660b
git-subtree-split: 720622da5451f3dc08fb2b90a7b060bfc4f4c6ed
@tahirmt
Copy link
Contributor Author

tahirmt commented Feb 16, 2025

@BobaFetters any idea when this will be released?

@BobaFetters
Copy link
Member

@tahirmt Not sure the exact day yet but we will likely do a release later this week once some other pending work is merged in as well.

@BobaFetters
Copy link
Member

@tahirmt We got the other pending work merged so will be going ahead and pushing a new release today

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.

Crash in WebSocketTransport due to data races
3 participants