hocuspocus icon indicating copy to clipboard operation
hocuspocus copied to clipboard

Prevent setTimeout buildup during frequent document updates

Open entropi opened this issue 5 months ago • 1 comments

Addresses https://github.com/ueberdosis/hocuspocus/issues/854

When making many edits to the same document within the disconnectTimeout window (1000ms by default), it's possible to stack a large number of redundant setTimeout calls. This tracks and clears any pending Timeouts when new hooks are fired against the same document.

in the case of afterStoreDocument, we immediately resolve the promise so that outstanding hooks complete. In the case of onDisconnect, we simply clear the timeout, since we'll set a new delayed disconnect call.

entropi avatar Sep 17 '24 15:09 entropi