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

Monaco ITextModel Out of Sync #7

Closed
2 tasks done
raedle opened this issue Jan 6, 2021 · 1 comment
Closed
2 tasks done

Monaco ITextModel Out of Sync #7

raedle opened this issue Jan 6, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@raedle
Copy link
Contributor

raedle commented Jan 6, 2021

Checklist

Describe the bug
Collaboratively editing in Monaco can break the ITextModel content (see screencast). It is reproducible if messages sent by the y-websocket are artificially delayed.

Note: the YText shared data type converges correctly. It's the Monaco editor that's not correctly reflecting the state of the shared type (see second screencast).

To Reproduce
Steps to reproduce the behavior:

  1. Clone yjs-demos project to yjs-demos
  2. (cd yjs-demos/demo-server && npm install)
  3. (cd yjs-demos/monaco && npm install)
  4. (cd yjs-demos/demo-server && npm install lib0)
  5. Copy y-websocket/bin/utils.js to yjs-demos/demo-server/utils.js
  6. Copy y-websocket/bin/callback.js to yjs-demos/demo-server/callback.js
  7. Change const setupWSConnection = require('y-websocket/bin/utils.js').setupWSConnection in yjs-demos/demo-server/demo-server.js to const setupWSConnection = require('./utils.js').setupWSConnection
  8. Wrap send in utils.js in a setTimeout with 15000 ms (https://github.com/yjs/y-websocket/blob/9fd8f41fa8f1e29e3d98e6de8156b4650a89c7f1/bin/utils.js#L217) to artificially delay sending messages to peer clients.
  9. (cd yjs-demos/demo-server && npm start)
  10. Change the WebsocketProvider in yjs-demos/monaco/monaco.js to connect to your local websocket server (i.e. const provider = new WebsocketProvider('ws://localhost:8080', 'monaco-demo', ydoc)
  11. (cd yjs-demos/monaco && npm start)
  12. Open Chrome and Firefox and navigate to http://localhost:8081/monaco/monaco.html in both browsers
  13. Edit in one Monaco editor (similar to what is shown in the screencast) and once the updates come in in the other Monaco editor, start editing concurrently.

Expected behavior
It is expected that both Monaco editors show the same content.

Screenshot
yjs-monaco

Screencast
https://user-images.githubusercontent.com/489051/103810010-583c2400-500f-11eb-99f2-35e58e5c9d70.mp4

Screencast (with YText content logged to console)
https://user-images.githubusercontent.com/489051/103834425-36a36280-5038-11eb-9456-d528c5c789e7.mp4

Environment Information

  • Node.js v10.16.3
  • Chrome Version 87.0.4280.88 (Official Build) (x86_64)
  • Firefox 84.0.1 (64-bit)
  • Yjs version and the versions of the y-* modules are the same as in the yjs-demos repo as of today
@raedle raedle added the bug Something isn't working label Jan 6, 2021
raedle added a commit to raedle/y-monaco that referenced this issue Jan 7, 2021
…lete ops when local ops are applied, which can lead to inconsistent ITextModels on the different clients. Using the ITextModel.applyEdits prevents these ops
raedle added a commit to raedle/y-monaco that referenced this issue Jan 7, 2021
…lete ops when local ops are applied, which can lead to inconsistent ITextModels on the different clients. Using the ITextModel.applyEdits prevents these ops
raedle added a commit to raedle/y-monaco that referenced this issue Jan 7, 2021
…lete ops when local ops are applied, which can lead to inconsistent ITextModels on the different clients. Using the ITextModel.applyEdits prevents these ops
@dmonad
Copy link
Member

dmonad commented Jan 8, 2021

Thank you for this detailed issue description. I was finally able to reproduce the issue reliably.

I merged your PR that fixes this issue. I also bumped the dependencies and allowed for current versions of the monaco editor.

The fix is published in y-monaco@0.1.2.

@dmonad dmonad closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants