Prevent Yjs unobserve warnings when destroy() runs after observers re…#29
Open
rahulCoder9417 wants to merge 1 commit intoyjs:masterfrom
Open
Prevent Yjs unobserve warnings when destroy() runs after observers re…#29rahulCoder9417 wants to merge 1 commit intoyjs:masterfrom
rahulCoder9417 wants to merge 1 commit intoyjs:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Are you reporting a bug?
Try to report your issue in the correct repository.
Describe the bug
Calling destroy() on a MonacoBinding instance causes Yjs to print warnings like:
[yjs] Tried to remove event handler that doesn't exist.
This happens when ytext.unobserve(this._ytextObserver) is executed after the observer has already been removed somewhere else.
The warning is harmless but noisy, and it appears frequently in projects where cleanup is triggered multiple times (e.g. hot reload, component unmounts, or integration with reactive frameworks).
To Reproduce
Create a MonacoBinding instance with a Y.Text.
Call destroy() more than once or manually call ytext.unobserve somewhere before the binding’s destroy logic runs.
Open the console.
Observe the Yjs warning:
[yjs] Tried to remove event handler that doesn't exist.
Expected behavior
destroy() should clean up safely without throwing Yjs warnings, even if the Y.Text observer was removed earlier or if destroy is called multiple times.
The method should either check before unobserving or handle the error silently.
Screenshots
N/A — console output only.
Environment Information
Browser / Node.js: (e.g. Chrome 129 / Node.js 18)
Yjs version: output of npm ls yjs
y-monaco / y-protocols / y-websocket versions