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 conversationsByTopic concurrency issues #160

Closed
wants to merge 3 commits into from

Conversation

nplasterer
Copy link
Contributor

Fixes #159

Use async and await to fix concurrency issues around conversationsByTopic that was causing crashes.

@nplasterer nplasterer self-assigned this Sep 17, 2023
let decoded = try conversation.decode(envelope)
continuation.yield(decoded)
} else if envelope.contentTopic.hasPrefix("/xmtp/0/invite-") {
let conversation = try fromInvite(envelope: envelope)
conversationsByTopic[conversation.topic] = conversation
async {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be awaits, not async tasks. If you make a task here, the loop can break before the dictionary value is written, so it will miss the subscription.

@nplasterer nplasterer closed this Sep 20, 2023
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.

Bug: Framework can cause app to crash due to variable data race with async access
2 participants