Skip to content

[Bug]: Yjs collaboration binding is recreated on every keystroke due to content in useEffect dependency array** #458

@Rishabhworkspace

Description

@Rishabhworkspace

Short summary

The Yjs/Monaco collaboration binding is torn down and rebuilt on every keystroke because content (the live file text) is incorrectly listed as a useEffect dependency.

Steps to reproduce

  1. Open any existing playground that has collaboration enabled.
  2. Open a file in the editor.
  3. Start typing in the Monaco editor.
  4. Open the Network tab in browser DevTools.
  5. Observe repeated requests to /api/collab-token firing on every keystroke.
  6. (Optional) Open the playground in two browser tabs — observe collaborator cursors flickering or disappearing while typing.

Expected behavior

The Yjs binding should be established once when the file or playground changes, and remain stable throughout the editing session. Typing should not trigger any network requests or re-initialise the binding.

Actual behavior

Every keystroke causes the useEffect in playground-editor.tsx (lines 274–413) to re-run because content is in the dependency array. This destroys the existing MonacoBinding, fetches a new collab token, and creates a new binding — dozens of times per second while typing. Collaborator cursors flicker and disappear.

Affected area

Playground editor

Environment

Any browser on any OS running Editron locally or deployed. Reproducible whenever a playground is open and the user types in the editor.

Screenshots, logs, or recordings

No response

Confirmation

  • I searched existing issues before opening this report.
  • I included enough detail for reproduction.

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions