Skip to content

fix: don't let pending shell operations block app exit on Windows - #52888

Merged
MarshallOfSound merged 1 commit into
mainfrom
fix/win-shell-tasks-continue-on-shutdown
Aug 17, 2026
Merged

MarshallOfSound merged 1 commit into
mainfrom
fix/win-shell-tasks-continue-on-shutdown

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Description of Change

Fixes #52141 (the crash cases > "promise-destroy-crash" flake on Windows), which turned out to be a real quit hang rather than a test problem.

  • shell.openExternal() / shell.openPath() / shell.showItemInFolder() post their ShellExecuteEx() work to a COM STA thread-pool task with the default SKIP_ON_SHUTDOWN behaviour. A SKIP_ON_SHUTDOWN task that has already started blocks ThreadPoolInstance::Shutdown(), and ShellExecuteEx() can block inside the OS for as long as Windows is showing UI for the request — e.g. the "you'll need a new app to open this link" dialog for a scheme with no registered handler (its helper thread sits in a synchronous cross-process COM release into OpenWith.exe until the dialog is dismissed). Net effect: app.quit() fires will-quit/quit, then the browser main thread parks in TaskTracker::CompleteShutdown() and the process never exits until the user clicks OK.
  • Post these tasks with CONTINUE_ON_SHUTDOWN instead. This matches Chrome's platform_util::OpenItem, which uses that trait for exactly this reason ("can hang shutdown without this trait as it may result in an interactive dialog"). The tasks only touch their bound arguments and OS APIs, so letting shutdown proceed while one is still blocked in the shell is safe.

Verified on Windows CI by looping the promise-destroy-crash fixture with native stack capture on hang: current behaviour hung 132/243 runs (main thread in TaskTracker::CompleteShutdown, worker in ShellExecuteExW → CShellExecute::_RunThreadMaybeWait, shell helper thread in combase!RemoteReleaseRifRef); with this change 0/243.

Checklist

Release Notes

Notes: Fixed an issue on Windows where the app process could fail to exit after app.quit() while a shell.openExternal() or shell.openPath() call was still waiting on a system "Open with" dialog.

shell.openExternal(), shell.openPath() and shell.showItemInFolder() run
ShellExecuteEx()/SHOpenFolderAndSelectItems() on a COM STA thread-pool
task with the default SKIP_ON_SHUTDOWN behaviour. A SKIP_ON_SHUTDOWN task
that has already started blocks ThreadPoolInstance::Shutdown(), and
ShellExecuteEx() can block inside the OS for as long as Windows is showing
UI for the request - for example the "you'll need a new app to open this
link" dialog for a URL scheme with no registered handler. The result is
that app.quit() never completes (the process lingers after 'quit' has
fired) until the user dismisses that system dialog.

Post these tasks with CONTINUE_ON_SHUTDOWN instead, matching Chrome's
platform_util::OpenItem, which uses that trait for the same reason. The
tasks only touch their bound arguments and OS APIs, so letting shutdown
proceed while one is still blocked in the shell is safe.

Fixes #52141.

No-Verification-Needed: Windows-only source not built on this host; verified via Windows CI experiment
@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. labels Aug 17, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Aug 17, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) August 17, 2026 05:38
@MarshallOfSound
MarshallOfSound merged commit c5845c2 into main Aug 17, 2026
141 of 143 checks passed
@MarshallOfSound
MarshallOfSound deleted the fix/win-shell-tasks-continue-on-shutdown branch August 17, 2026 08:11
@release-clerk

release-clerk Bot commented Aug 17, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue on Windows where the app process could fail to exit after app.quit() while a shell.openExternal() or shell.openPath() call was still waiting on a system "Open with" dialog.

@trop

trop Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #52897

@trop

trop Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #52898

@trop trop Bot removed the target/43-x-y PR should also be added to the "43-x-y" branch. label Aug 17, 2026
@trop

trop Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #52899

@trop

trop Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #52900

@trop trop Bot added in-flight/41-x-y in-flight/42-x-y merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. and removed target/44-x-y PR should also be added to the "44-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/43-x-y in-flight/44-x-y in-flight/41-x-y labels Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

45-x-y in-flight/42-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. new-pr 🌱 PR opened recently semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Flaky test: crash cases "promise-destroy-crash" should not crash (win)

2 participants