Skip to content

fix(project): Cancel pending settle timer before watcher recovery - #1528

Open
matz3 wants to merge 1 commit into
mainfrom
fix/project-watcher-cancel-settle-timer
Open

fix(project): Cancel pending settle timer before watcher recovery#1528
matz3 wants to merge 1 commit into
mainfrom
fix/project-watcher-cancel-settle-timer

Conversation

@matz3

@matz3 matz3 commented Aug 18, 2026

Copy link
Copy Markdown
Member

On Windows, a settle timer callback firing into a closed ReadDirectoryChangesW handle after recovery causes an access violation (0xC0000005). Cancel any pending timer before tearing down the subscriptions; it is re-armed by the first event on the new set.

Extract the timer-cancel and subscription-drain logic shared by #recoverWatcher and destroy into #cancelSettleTimer and #drainSubscriptions helpers to remove the duplication.

This should resolve the flaky test observed via #1524 (comment).

@matz3
matz3 requested a review from a team August 18, 2026 07:28
@matz3
matz3 enabled auto-merge (rebase) August 18, 2026 10:00
Comment on lines +233 to +236
// Cancel any pending settle timer before tearing down the subscriptions. On Windows,
// ReadDirectoryChangesW holds a raw HANDLE; a timer callback firing into a closed handle
// after recovery causes an access violation (0xC0000005). The timer is re-armed naturally
// by the first event that arrives on the new subscriptions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all the resoning here. I think there's much detail that needs a deeper look to understand the root cause.
From my perspective, it's completely resonable and expected to clear timeouts before releasing the property. Otherwise, side effects (like the one above) can be expected

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thats right. Thanks for pointing that out. I removed it and refactored the code.

d3xter666
d3xter666 previously approved these changes Aug 18, 2026

@d3xter666 d3xter666 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

On Windows, a settle timer callback firing into a closed
ReadDirectoryChangesW handle after recovery causes an access violation
(0xC0000005). Cancel any pending timer before tearing down the
subscriptions; it is re-armed by the first event on the new set.

Extract the timer-cancel and subscription-drain logic shared by
#recoverWatcher and destroy into #cancelSettleTimer and
#drainSubscriptions helpers to remove the duplication.
@matz3
matz3 force-pushed the fix/project-watcher-cancel-settle-timer branch from fe7fc7e to 9744c52 Compare August 18, 2026 12:35
@matz3

matz3 commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

The CI ran into a timeout on Windows, so this PR is most likely not solving all the current issues of flaky tests. I will continue investigating tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants