Skip to content

Cancel pending change delayer on cleanup and handle re-entrant delayer tasks - #1920

Open
Abhinav Maurya (Fire162) wants to merge 1 commit into
microsoft:mainfrom
Fire162:fix/delayer-pending-change-cleanup
Open

Abhinav Maurya (Fire162) wants to merge 1 commit into
microsoft:mainfrom
Fire162:fix/delayer-pending-change-cleanup

Conversation

@Fire162

Copy link
Copy Markdown

When a client stops while an edit is debounced during full text document sync, cleanUp() cancels _fileEventDelayer but leaves _pendingChangeDelayer scheduled. When the timer fires without an active connection, it re-triggers delivery and hits a TypeError: this.task is not a function because the running task continuation cleared this.task after the re-entrant trigger.

Cancel _pendingChangeDelayer in cleanUp() and detach this.task before running it in Delayer.trigger() and Delayer.forceDelivery().

Fixes #1916

…r tasks

cleanUp() cancelled _fileEventDelayer but left _pendingChangeDelayer running.
When a client stopped during the 250 ms debounce of a full text document sync,
the armed timer fired after shutdown, attempted to re-trigger delivery without an
active connection, and threw a TypeError because the running continuation cleared
this.task after the re-entrant trigger.

Cancel _pendingChangeDelayer in cleanUp() and detach this.task before running it
in Delayer.trigger() and Delayer.forceDelivery().
Copilot AI balanced review requested due to automatic review settings October 24, 2026 02:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes address both reported failure causes, with no identified blocking issues in the supplied review evidence.

No open issues 🎉

What changed in this PR

This PR fixes the pending full-document-sync shutdown error reported in #1916 and makes the client’s Delayer safe for tasks that schedule another task.

Changes:

  • Cancel pending change delivery during client cleanup.
  • Clear the current delayer state before invoking tasks in trigger() and forceDelivery().
  • Add a regression test for a task that triggers the delayer again.
File Description
client/​src/​common/​utils/​async.ts Preserve newly scheduled tasks during re-entrant delivery.
client/​src/​common/​client.ts Cancel the pending-change delayer during cleanup.
client-node-tests/​src/​converter.test.ts Test re-entrant task scheduling.

Review effort: Balanced

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.

Stopping a client with a pending full-sync didChange logs "Delivering pending changes failed: TypeError: this.task is not a function"

2 participants