Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

Fix duplicate notifications by removing leftover WorkManager with different unique work name#6126

Merged
TimoPtr merged 6 commits intohome-assistant:mainfrom
marazmarci:fix/duplicate-notifications
Dec 4, 2025
Merged

Fix duplicate notifications by removing leftover WorkManager with different unique work name#6126
TimoPtr merged 6 commits intohome-assistant:mainfrom
marazmarci:fix/duplicate-notifications

Conversation

@marazmarci
Copy link
Contributor

Summary

Fixes #6066, where users were getting duplicate notifications over the persistent WebSocket connection. The bug was introduced in #5998, where the periodic WorkManager work request's unique name was renamed from WebSockManager to WebSocketManager. This change resulted in two periodic jobs, because the old one was still persisted, and scheduled to try to start every 15 minutes.

I used the App Inspection feature of Android Studio to see the list of WorkManager jobs, and I was able to capture this screenshot:

image

Here you can see two instances of WebsocketManager running at the bottom of the list. Unfortunately this tool cannot show the unique name of the jobs, but the fact that two of the same type are running should be enough proof.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Any other notes

Copy link
Member

@TimoPtr TimoPtr left a comment

Choose a reason for hiding this comment

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

Very nice finding! For clarity purpose please add documentation explaining why we do that and link it to your comment in the issue. Also this should be removed after some time from the codebase.

@marazmarci
Copy link
Contributor Author

Thanks for the quick review, I added an explanation comment in 4cb2f69! Please check it out.

Do you have any reliable way to schedule a reminder to remove it, preferably so that every contributor gets a notification through GitHub? I was thinking about scheduling an email response to this thread in Gmail, which should add a comment here. And what do you think about let's say 1 year from now, to give enough time for everyone to update? Or is 1 year too long? Or from another perspective, is there anything that's hurrying us to remove it, except for the risk of forgetting (which a scheduled notification solves)?

@TimoPtr
Copy link
Member

TimoPtr commented Dec 4, 2025

Thanks for the quick review, I added an explanation comment in 4cb2f69! Please check it out.

Do you have any reliable way to schedule a reminder to remove it, preferably so that every contributor gets a notification through GitHub? I was thinking about scheduling an email response to this thread in Gmail, which should add a comment here. And what do you think about let's say 1 year from now, to give enough time for everyone to update? Or is 1 year too long? Or from another perspective, is there anything that's hurrying us to remove it, except for the risk of forgetting (which a scheduled notification solves)?

We probably should create an issue with a due date. 1 year seems reasonable. Then in the code add a link to this issue. It's only important for anyone that might work on this code later and could remove it if doing some refactor or something instead of keeping the logic forever.

@marazmarci
Copy link
Contributor Author

Nice, I didn't know GitHub allows you to set a due date on an issue!

To prevent accidental removal of the cancelUniqueWork call, I added a Please don't remove before December 2026 to allow enough time for users to upgrade. comment to the code!

Copy link
Member

@TimoPtr TimoPtr left a comment

Choose a reason for hiding this comment

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

Thanks again 👍🏻

@TimoPtr
Copy link
Member

TimoPtr commented Dec 4, 2025

Nice, I didn't know GitHub allows you to set a due date on an issue!

I don't think it can but we can simply write it down in the issue. But don't worry let's keep it like this for now.

@TimoPtr TimoPtr enabled auto-merge (squash) December 4, 2025 08:13
@TimoPtr TimoPtr merged commit 9ea8520 into home-assistant:main Dec 4, 2025
31 of 33 checks passed
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.

Duplicate Notifications when using persistent connection (websocket)

2 participants