Reload page on system resume to fix stale Messenger connection - #2384
Reload page on system resume to fix stale Messenger connection#2384worthyfarmstead-rgb wants to merge 1 commit into
Conversation
After a system suspend/wake cycle, the long-poll/WebSocket connection to messenger.com is silently broken. This adds a powerMonitor 'resume' listener that waits for network connectivity via ensureOnline(), then reloads the page to restore the connection without user intervention. Fixes sindresorhus#103 Co-Authored-By: Paperclip <noreply@paperclip.ing>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bd020aef9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // before reloading to avoid a blank page on slow reconnects. | ||
| // See: https://github.com/sindresorhus/caprine/issues/103 | ||
| powerMonitor.on('resume', async () => { | ||
| await ensureOnline(); |
There was a problem hiding this comment.
Avoid interactive offline prompt in resume handler
Calling ensureOnline() in the powerMonitor resume callback makes every wake-from-sleep path inherit startup behavior that shows a synchronous “Wait/Quit” dialog (and can call app.quit()) when connectivity is missing for ~15 seconds. In practice, users who resume without network (airplane/train, captive portal, Wi‑Fi still reconnecting) can get an unexpected blocking prompt or have the app quit even though they did not explicitly relaunch; this is a regression in the resume flow and should use a non-interactive connectivity wait/fallback.
Useful? React with 👍 / 👎.
Summary
After a system suspend/wake cycle, the long-poll/WebSocket connection to messenger.com is silently broken — no new messages arrive and sends fail until the user manually presses
Cmd+R. This is a known issue noted in the code itself (theelectronDebugcall at the top ofindex.tsexplicitly keeps debug mode on for this reason).Fix
Listen for Electron's
powerMonitorresumeevent. When the system wakes:ensureOnline()utility (polls every second withp-wait-for+is-online) to avoid a blank page on slow reconnects — as raised by @veniversum in the issue thread.No new dependencies. Uses only Electron built-ins and the already-imported
ensureOnlinehelper.Testing
pmset sleepnow).Fixes #103