Fix: avoid connection-error spam from background refresh after system sleep - #292
Open
px-pole wants to merge 2 commits into
Open
Fix: avoid connection-error spam from background refresh after system sleep#292px-pole wants to merge 2 commits into
px-pole wants to merge 2 commits into
Conversation
… sleep Background scheduled refresh/notif-check timers are wall-clock based, so after the PC wakes from sleep the overdue timer fires immediately, before the network is back up, producing a pile of connection error popups. - Detect a sleep/resume gap (wall clock jumping ahead of monotonic clock) and push pending bg timers forward instead of firing them right away. - Add utils.is_network_available() and use it to silently defer the scheduled bg refresh/notif check (retry every 15s) until the network is reachable, instead of surfacing a connection error popup.
There was a problem hiding this comment.
🟡 Changes recommended
There is an unused import in modules/gui.py and the new synchronous DNS probe can block the GUI main loop during DNS/network outages.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adjusts the tray/background refresh loop to avoid spamming connection-error popups immediately after system resume (when timers are overdue but networking/DNS may not be ready yet).
Changes:
- Add
utils.is_network_available()to gate background refresh/notif checks until connectivity is present. - Detect suspend/resume gaps by comparing wall-clock vs monotonic deltas and push background timers forward on wake.
- Defer scheduled background refresh/notif tasks by rescheduling short retries when the network check fails.
File summaries
| File | Description |
|---|---|
| modules/utils.py | Adds a synchronous network-availability probe used to defer background tasks. |
| modules/gui.py | Adds sleep/resume detection and uses the network probe to delay tray-mode refresh/notif checks. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…cking - Remove unused `socket` import from modules/gui.py. - modules/utils.py: is_network_available() no longer calls socket.getaddrinfo() synchronously on the caller's thread (which could block the GUI main loop for seconds during DNS/network outages). It now returns a cached last-known state and refreshes it via a daemon background thread, so the main loop never blocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The background (tray) mode refresh/notification-check timers in `modules/gui.py` are wall-clock based (`time.time()`). When the PC goes to sleep, the wall clock keeps advancing (RTC), so the scheduled timer is already overdue the moment the system resumes. The app then immediately tries to refresh, before the network adapter/DNS/DHCP has reconnected, causing a batch of connection error popups that pile up in the popup stack.
Fix
Testing
Manually verified the background loop logic; suspended/resumed a test machine and confirmed the scheduled refresh no longer fires until DNS resolution succeeds again.