Skip to content

fix: don't spin forever on unhandled file change actions (windows) - #1152

Open
mfisher31 wants to merge 1 commit into
mainfrom
element-exe-non-scanner-hang
Open

fix: don't spin forever on unhandled file change actions (windows)#1152
mfisher31 wants to merge 1 commit into
mainfrom
element-exe-non-scanner-hang

Conversation

@mfisher31

Copy link
Copy Markdown
Member

The Windows FileSystemWatcher walked the FILE_NOTIFY_INFORMATION list with a that skipped unknown actions without advancing to the next entry, so any notification Windows delivers outside the five handled actions (alternate data stream and file id notifications, as generated by OneDrive and similar) pinned the watcher thread in an infinite loop at 100% CPU while holding its lock. The thread then no longer reached threadShouldExit(), so shutdown fell back to TerminateThread and the process could outlive a normal quit.

Skip unrecognized actions instead of looping on them, bound the buffer walk by the returned byte count, align the buffer as ReadDirectoryChangesW requires, and stop retrying a failed read in a tight loop (recovering on ERROR_NOTIFY_ENUM_DIR with a full folder refresh).

The Windows FileSystemWatcher walked the FILE_NOTIFY_INFORMATION list with
a  that skipped unknown actions without advancing to the next
entry, so any notification Windows delivers outside the five handled
actions (alternate data stream and file id notifications, as generated by
OneDrive and similar) pinned the watcher thread in an infinite loop at
100% CPU while holding its lock.  The thread then no longer reached
threadShouldExit(), so shutdown fell back to TerminateThread and the
process could outlive a normal quit.

Skip unrecognized actions instead of looping on them, bound the buffer
walk by the returned byte count, align the buffer as ReadDirectoryChangesW
requires, and stop retrying a failed read in a tight loop (recovering on
ERROR_NOTIFY_ENUM_DIR with a full folder refresh).
@mfisher31 mfisher31 self-assigned this Aug 7, 2026
@mfisher31 mfisher31 moved this to In progress in Element 1.2.x Aug 7, 2026
@mfisher31
mfisher31 marked this pull request as ready for review August 8, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

1 participant