Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent setTimeout buildup during frequent document updates #855

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

entropi
Copy link

@entropi entropi commented Sep 17, 2024

Addresses #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.

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.
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.

1 participant