Hi, I am attempting to offer users to upload a locally created document to a shared document:
const yDoc = new Y.Doc();
const yMap = yDoc.getMap('crazyWall');
const unbind = bind<any>(WallProxy /* valtio proxy storing the JSON document */, yMap);
// I did test this, binding late does populate the empty storage with content from the other,
// printing the below buffer shows that it changes with differing input.
const state = Y.encodeStateAsUpdateV2(yDoc);
const buffer = Buffer.from(state);
return (await fetch("/api/newdoc", {
method: "POST",
body: buffer
}).then(r => r.json())).docId;
(See https://github.com/MaSp005/crazywall/blob/f10831b51944dd1dfed6c4c7f96e99f3fe0c6f1a/src/contexts/globalContext.ts#L276-L291)
The server will then create the document with the uploaded content:
const body = await request.arrayBuffer();
const content = new Uint8Array(body);
// This stores the same bytes as the buffer on the client.
const { docId } = await yManager.createDocWithContent(content);
(See https://github.com/MaSp005/crazywall/blob/f10831b51944dd1dfed6c4c7f96e99f3fe0c6f1a/src/index.ts#L70-L94)
Expected behaviour: Viewing the created document shows the exact state as uploaded before.
Observed behaviour: Visiting the created document afterwards shows an entirely empty document.
I attempted to step through the y-sweet server, and the update from the backend does reach DocWithSyncKv#apply_update, but I couldn't trace it further.
Is this an issue with my usage of the library or a bug with the server? Thanks!
Hi, I am attempting to offer users to upload a locally created document to a shared document:
(See https://github.com/MaSp005/crazywall/blob/f10831b51944dd1dfed6c4c7f96e99f3fe0c6f1a/src/contexts/globalContext.ts#L276-L291)
The server will then create the document with the uploaded content:
(See https://github.com/MaSp005/crazywall/blob/f10831b51944dd1dfed6c4c7f96e99f3fe0c6f1a/src/index.ts#L70-L94)
Expected behaviour: Viewing the created document shows the exact state as uploaded before.
Observed behaviour: Visiting the created document afterwards shows an entirely empty document.
I attempted to step through the y-sweet server, and the update from the backend does reach
DocWithSyncKv#apply_update, but I couldn't trace it further.Is this an issue with my usage of the library or a bug with the server? Thanks!