codepod-io / codepod

Codepod IDE: Scalable Interactive Coding
https://codepod.io
MIT License
74 stars 15 forks source link

fix: queue sync1 message and handle it after ydoc is loaded #445

Closed lihebi closed 1 year ago

lihebi commented 1 year ago

Loading persisted ydoc takes time, and if SyncStep1 is sent/received before ydoc is ready, the message is discarded, causing provider.synced event never being fired.

This PR adds messages to a queue and processes them after ydoc is loaded from persistence. Ref: https://github.com/yjs/y-websocket/issues/81#issuecomment-1453185788