Repository navigation
Conversation
On Windows, 'before-quit' and 'will-quit' are not emitted on system shutdown, restart or user logoff. app.exit() skips both events on all platforms. In these cases the session stayed 'ok' on disk and the next start reported it as 'abnormal'. Now the session is written to disk as 'exited' on the BrowserWindow 'session-end' event (Windows) and when app.exit() is called. The write is synchronous because the process can end before async work finishes. On the next start, a persisted 'exited' session is sent as is, unless a crash is found.
From Electron 43, process.exit() calls app.exit(). The SDK now treats app.exit() as a clean exit, so these tests got an 'exited' session. SIGKILL gives a real abnormal exit on all Electron versions.
timfish
marked this pull request as ready for review
November 3, 2026 11:39
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6d9acee. Configure here.
An async set() that started before setSync() could finish after it and write the old 'ok' session back to disk. Async writes queued before a sync write are now skipped. If a sync write happens while an async write runs, the sync data is written again.
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.

Fixes #1477
On Windows,
before-quitandwill-quitare not emitted on system shutdown, restart or user logoff.app.exit()skips both events on all platforms. In these cases the main process session stayedokon disk, and the next start reported it asabnormal. Long-running tray apps got an abnormal session after every reboot.Changes
session-endevent on everyBrowserWindow. When it fires, write the session to disk asexited.app.exit()so that it writes the session to disk asexitedbefore the app exits.Store.setSync()), because Windows can end the process soon aftersession-endand async work may not finish.will-quit, the normal path sends the session and clears the file, so it is not sent twice.exitedsession is sent with its original end time and duration. If a minidump from the previous run is found, the session is still reported ascrashed.previousSessionWasAbnormal()now callscheckPreviousSession(false)instead of duplicating its code.Behaviour change:
process.exit()From Electron 43,
process.exit()in the main process callsapp.exit(). Because of this, a session that ends withprocess.exit()is now reported asexitedon Electron 43 and later. On older Electron versions it is still reported asabnormal.The
abnormal-exitandabnormal-exit-electron-uploadere2e tests usedprocess.exit()to simulate an abnormal exit, so they now kill the app withSIGKILL. This gives a real abnormal exit on all Electron versions.Limitations
abnormalafter a shutdown, becausesession-endis aBrowserWindowevent and Electron has no app-level equivalent on Windows.session-endpath is not covered by an automated test, because it needs a real Windows logoff or shutdown.Tests
sessions/app-exit: the first run exits withapp.exit(), and the second run must send that session asexited. It fails onmasterwithabnormal.Generated by Claude Code