{{ message }}
feat: add query-session-end and improve session-end events on Windows#44598
Merged
Conversation
56e93f4 to
6211b11
Compare
5 tasks
99bba84 to
0ed2322
Compare
codebytere
requested changes
Nov 13, 2024
codebytere
left a comment
Member
There was a problem hiding this comment.
Thanks for working on this!
Contributor
Author
|
@codebytere thanks for the review! Everything sounds reasonable. I would commit fixes soon. |
samuelmaddock
requested changes
Nov 13, 2024
samuelmaddock
requested changes
Nov 13, 2024
samuelmaddock
approved these changes
Nov 18, 2024
Co-authored-by: Sam Maddock <samuel.maddock@gmail.com>
Contributor
Author
|
Nevermind, it was a flaky test. |
itsananderson
left a comment
Member
There was a problem hiding this comment.
Left a small suggestion for the session-end event, but overall API LGTM
Co-authored-by: Will Anderson <will@itsananderson.com>
Contributor
Author
|
@itsananderson @samuelmaddock @codebytere requesting a last review I hope! Fixed everything you highlighted. |
itsananderson
approved these changes
Nov 21, 2024
itsananderson
left a comment
Member
There was a problem hiding this comment.
Thanks for submitting this!
VerteDinde
approved these changes
Nov 21, 2024
codebytere
approved these changes
Nov 22, 2024
|
Congrats on merging your first pull request! 🎉🎉🎉 |
This was referenced Jan 18, 2025
5 tasks
ostend972
added a commit
to ostend972/test
that referenced
this pull request
Nov 11, 2025
…SSION)
Fix définitif du proxy résiduel lors de l'arrêt Windows - Utilisation de l'événement natif
Problème avec v1.0.13 :
- powerMonitor.on('shutdown') ne fonctionne PAS sous Windows
- C'est un bug connu d'Electron : l'événement shutdown n'est pas implémenté pour Windows
- Le proxy restait donc actif après redémarrage, bloquant internet
Solution v1.0.14 :
- Utilisation de mainWindow.on('session-end') qui intercepte WM_ENDSESSION
- WM_ENDSESSION est le vrai message système Windows d'arrêt/redémarrage
- Beaucoup plus fiable et natif à Windows
- Code : main.js:131-151 (gestionnaire session-end sur BrowserWindow)
Améliorations techniques :
- Désactivation synchrone du proxy en 1.5s max (au lieu de 2s)
- Triple nettoyage : netsh + Registry ProxyEnable + Registry ProxyServer
- Logs détaillés avec les raisons (shutdown, logoff, close-app, critical)
- Documentation : WindowSessionEndEvent Electron
Sources :
- https://www.electronjs.org/docs/latest/api/structures/window-session-end-event
- electron/electron#21093 (powerMonitor shutdown ne fonctionne pas)
- electron/electron#44598 (amélioration session-end)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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.

Description of Change
Current Electron version allows to handle only
WM_ENDSESSION, but notWM_QUERYENDSESSION. This cause a lot of problems while Electron app is packaged into own MSI and is a menubar/tray app. For example currently we cannot close app using Restart Manager which is used by default since Windows Installer 4.0. We have to use util:CloseApplication or calltaskkil.Quote from Restart Manager guidelines for Applications:
So to properly close GUI app we need to handle
WM_QUERYENDSESSIONproperly and returnTRUE. But for now for any unknown WM message it will cause us to return FALSE (see calling code: https://github.com/chromium/chromium/blob/134896c2d6148c6bd2f7b096b0664b1e4013cb5c/ui/views/win/hwnd_message_handler.cc#L1069).My implementation will return TRUE by default (in case of
WM_QUERYSESSION), so it could probably fix longstanding issues like this: #15880.ev.preventDefault()can still return old behaviour.Also both
query-session-endandsession-endnow return a reasons why they receiving this event, it could beshutdown,close-app,criticalandlogoff.Checklist
npm testpassesRelease Notes
Notes: Added
query-session-endevent and improvedsession-endevents on Windows