-
Notifications
You must be signed in to change notification settings - Fork 13
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
✨Collaboration long polling fallback #517
base: main
Are you sure you want to change the base?
Conversation
1360973
to
55238a7
Compare
137c5b1
to
ff343ca
Compare
ff343ca
to
d95e892
Compare
Great job @AntoLC ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AntoLC Nice you got this working. If I see it correctly, you created a new endpoint over which you're always syncing the entire Y.Doc to and from the server.
If I'm not mistaken, normally the Y.js sync protocol is more efficient than this and syncs the exact updates required. What's the reason you went for this approach (new endpoint, syncing entire doc) instead of the proxy approach? I think the proxy approach has some potential advantages:
- We can keep the same sync protocol, but just switch to a different transport (more efficient and awareness would still work)
- The HocusPocus side can stay the same, our "fix" would be isolated to a separate layer) (less code complexity and smaller chance of bugs or security issues)
I might be missing some advantages of your current approach, but my concern is mainly that it adds more "custom code" that's another surface we need to test, maintain and secure. The proxy approach would isolate / limit this more I think
src/frontend/apps/impress/src/core/config/hooks/useCollaborationUrl.tsx
Outdated
Show resolved
Hide resolved
b24b01c
to
3eb9f69
Compare
b8ff4ad
to
c64f1f2
Compare
c64f1f2
to
d26da26
Compare
You can test this PR before it is merged on https://docs-ia.beta.numerique.gouv.fr/. Example public doc: https://docs-ia.beta.numerique.gouv.fr/docs/481a9933-3514-4aeb-9877-c21be1388877/?withoutWS=true |
d26da26
to
6355348
Compare
The environment was missing in the Sentry configuration. This commit adds the environment to the Sentry configuration.
We can now interact with the collaboration server using http requests. It will be used as a fallback when the websocket is not working. 2 kind of requests: - to send messages to the server we use POST requests - to get messages from the server we use a GET request using SSE (Server Sent Events)
We will need toBase64 in different features, better to move it to "doc-management".
6f8744e
to
c096f35
Compare
Create the CollaborationProvider class. This class is inherited from HocuspocusProvider class. This class integrate a fallback mechanism to handle the case where the user cannot connect with websockets. It will use post request to send the data to the collaboration server. It will use an EventSource to receive the data from the collaboration server.
We adapt the nginx configuration to works with http requests and on the collaboration routes. Requests are light but quite network intensive, so we add a cache system above "collaboration-auth". It means the backend will be called only once every 30 seconds after a 200 response.
We adapt the nginx configuration to works with http requests and on the collaboration routes. Requests are light but quite network intensive, so we add a cache system above "collaboration-auth". It means the backend will be called only once every 30 seconds after a 200 response.
Firefox with websocket Other without
c096f35
to
56f9a00
Compare
Purpose
Some users have their websockets blocked, so they cannot collaborate.
If they are connected with other collaborators at the same time, it will create constant conflict in the document.
Proposal
We have succeeded to propose an experience almost as good as with websocket.
y-protocols/sync
making our request very light (a few bytes).to pull data, to minimize the requests amount and keep as much as possible our documents sync between each others.
Cases we solved:
Architecture