-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
feat: support 'shutdown' on Windows #24261
Conversation
39992c5
to
ea5a88e
Compare
: " on browser process")); | ||
if (blocker && !blocker->OnQueryEndSession()) { | ||
LOG(INFO) << "Shutdown blocked"; | ||
ShutdownBlockReasonCreate(hwnd, L"Ensure a clean shutdown"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider making this string configurable - this gets shown on shutdown to users and if it's hard-coded to English, this will result in a Confusing Experience™™™ to people using non-English locales!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh excellent point, will do!
d6e0f19
to
d3bd580
Compare
|
||
export function setup (binding: typeof process['_linkedBinding']) { | ||
// TODO(codebytere): fix typedef here. | ||
(binding as any).setShutdownHandler(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shutdown handler in renderer returns undefined
, which would then always cancel the shutdown.
// so, as explained here | ||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa376890(v=vs.85).aspx | ||
// | ||
// The WM_QUERYENDSESSION message must be handled in every every process managed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the WM_QUERYENDSESSION
message, but if it must be handled in every process then we also need to handle it in GPU/utility/network/... processes then.
66a38c2
to
1ebc77e
Compare
Any updates on this? |
@LorenzoBiondani none at the moment but i haven't forgotten about it! i'll work on it more this week |
1ebc77e
to
27a6bba
Compare
@codebytere thank you, I don't have much time that I can dedicate to this but if you need something let me know, I will try to help. |
// so, as explained here | ||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa376890(v=vs.85).aspx | ||
// | ||
// The WM_QUERYENDSESSION message must be handled in every every process managed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo / repeated word:
"handled in every every process" should be "handled in every process"
: " on browser process")); | ||
if (blocker && !blocker->OnQueryEndSession()) { | ||
LOG(INFO) << "Shutdown blocked"; | ||
ShutdownBlockReasonCreate(hwnd, L"Ensure a clean shutdown"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling ShutdownBlockReasonCreate()
inside the WM_QUERYENDSESSION
handler allows us to notify our code to clean up and shutdown quickly, but we can also use it preemptively when we know that we're running a critical section, like burning a cd, or saving a file to disk.
It would be really nice if an app could call a "block" or "unblock" API when the programmer knows in advance where a shutdown should be blocked, releasing the block afterwards. The "block" API would call ShutdownBlockReasonCreate(hwnd, L"A critical task is running.");
The "unblock" API would call ShutdownBlockReasonDestroy(hwnd);
The string passed into ShutdownBlockReasonCreate()
is shown by windows as the reason for the shutdown being held up.
Is anyone pushing this merge? |
any updates on this? |
hello, your pull request is not merge successful, can you fix it and pull again? 3Q |
Related: #15880 |
Any updates on this? In the meantime I've created a node addon which can be used to detect and to block the shutdown of the system in electron: https://www.npmjs.com/package/@paymoapp/electron-shutdown-handler |
Can someone explain why we need to handle events from both browser and renderer? cc @codebytere |
Was this issue addressed in the end? Docs say that shutdown for powerMonitor is Linux and MacOS only |
Description of Change
Take 2 of #15620.
From initial PR:
Checklist
npm test
passesRelease Notes
Notes: Add Windows implementation of powerMonitor "shutdown" event