I built upon this work from this repo to run yjs websockets in a serverless environment. I rewrote in typescript, and made it a tad easier to work with locally (after you deploy the db).
Try it here:
It uses AWS Lambda alongside DynamoDB to maintain socket connections.
A few unique things that I learned:
AWS Lambda supports only supports passing strings as responses. So we need to pass updates to the server and back as base64 strings, and not the standard binary type. This means the y-websocket client doesn’t work out of the box, you need to make a custom copy.
Handling Awareness? I wasn’t entirely clear on how to handle awareness data properly. Right now it just broadcasts the message. In an ideal world, it’s passed to clients as part of the initial document as well.
There was some feedback on the original repo for areas to improve. I tried to apply the updates on just the change vectors, and during updates, but I couldn’t really figure it out.
It does work, but I’m not sure what the right way is to test all of the test cases because it’s not perfect.
To make tweaks, the real work happens in this file in a series of three handlers for the sockets.
Hi. This is awesome starting point, thank you for sharing.
I see that you have not update the repo for quite a while.
Have you went to production with your code successfully?
I am experiencing strange issue from time to time. Changes got synced between clients, however, document updates are not written to DynamoDB table. Therefore content got lost. I was unable to find source of this issue yet. Do you have any ideas of how to deal with this?
Also, have you considered what to do once document reaches 400 Kb size?