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 race condition in websocket unsubscribe/resubscribe #2855

Merged
merged 1 commit into from Sep 5, 2022

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Sep 5, 2022

Summary

If the app tried to start a new websocket subscription before the last one with the same message/data was properly unsubscribed, the app would return a flow that is null and crash. To prevent this, change the unsubscribe logic to immediately remove the subscription ID (the confirmation isn't used). This will allow the app to start a new subscription and create a new flow even if the previous unsubscribe hasn't yet fully finished.

More info and reproduction steps in the original issue, which this PR fixes: #2852

Screenshots

n/a

Link to pull request in Documentation repository

n/a

Any other notes

 - If the app tries to start a new websocket subscription before the last one was properly unsubscribed, the app will return a flow that is null and crash. To prevent this, change the unsubscribe logic to immediately remove the subscription ID - the confirmation isn't used. This will allow the app to start a new subscription and create a new flow even if the previous unsubscribe hasn't yet fully finished (which is OK).
@JBassett JBassett merged commit 45cdaeb into home-assistant:master Sep 5, 2022
@jpelgrom jpelgrom deleted the fix-2852 branch September 6, 2022 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Websocket nullpointerexceptions for subscribeTo
4 participants