Discussions related to Shared Editing, Distributed Apps, and Yjs. Questions about Yjs should go to discuss.yjs.dev. Bug reports to the issue tracker.
Hey there. I'm using webrtc with the default setup and I'm receiving this error:
WebSocket connection to 'wss://y-webrtc-signaling-us.herokuapp.com/' failed:
setupWS @ websocket.js:25
WebsocketClient @ websocket.js:122
SignalingConn @ y-webrtc.js:473
(anonymous) @ y-webrtc.js:610
setIfUndefined @ map.js:49
(anonymous) @ y-webrtc.js:610
connect @ y-webrtc.js:609
WebrtcProvider @ y-webrtc.js:595
loadDoc @ space.js?t=1664184681825:125
Is there anything I'm doing wrong or is the signaling service down?
Thanks, saw your comment @dmonad on y-websocket
.
However, the on('synced', ...
does not 'fire'. You mention in your example it is 'hard to determine'. So how would I "return" the subdocument on my client?
My example: https://dpaste.org/dPPbt
If you need the granularity, use a Y.Map. If not, prefer a simple JSON object (FYI Yjs accepts all kinds of JSON objects, so no need for JSON.stringify).
I'm not sure what the code on dpaste is supposed to do. The synced event only works if you use a provider. Please read the official documentation: https://docs.yjs.dev/api/subdocuments
@dmonad Thanks. I've been through the docs but it still not quite clear
For the relationship between a "subDocs" & "folder"- is it possible to get "subDocs" from multiple folders?
You say "Yjs accepts all kinds of JSON objects" but how in my example would I do that? My attempt is below, which fails saying subDoc.set is not a function
. I tried using const subDoc = new Y.Doc(); subDoc.getText().insert(0, {foo:123})
but that also returns blank unless I "JSON.stringify" it
const folder = rootDoc.getMap()
const subDoc = new Y.Doc()
subDoc.getMap()
subDoc.set(data.id, data)
folder.set(data.id, subDoc)
WebSocket connection to 'wss://signaling.yjs.dev/' failed: Error during WebSocket handshake: Unexpected response code: 503
y-webrtc-signaling-us.herokuapp.com
server is failing because it seems that the y-webrtc client auto retries the server every second even if it can connect to other servers, effectively ddosing the server whenever it is down or client-server round trip latency goes above 1000ms.
Hey. I have a nested Y.Map structure like that:
parentMap<Y.Map> = {
childId1: <Y.Map> { ...childProperties },
childId2: <Y.Map> { ...childProperties }
}
and want to use the Y.UndoManager like that:
const newUndoManager = new Y.UndoManager(parentMap);
Now. I can undo and redo events on the parentMap (e.g., add child, or remove child) but not events on the childs (i.e., property changes). As I understand the docs, this should be possible. Is there somewhere an example on how to do it?
@dmonad Thanks for your responses, I have been trying to figure it out but I'm still stuck. This is an example adapting from y-websocket
- I'm basically trying to only return a subset of the result when it goes to getYDoc
Y.RelativePosition
thing: https://docs.yjs.dev/api/relative-positionsY.Doc()
. Maybe I'm seriously misunderstanding something, though.
Hi @anne_biene_twitter,
They can be used with anything that looks like an Array (Y.Text, Y.Array, Y.XmlElement, Y.XmlFragment) ;)
@MaxNoetzold, the docs that you linked explain how you can add support to your existing provider (it's only a few lines of code).
@jclem
The subdocs documentation seems to imply that creating subdocs does not merge—is this correct? What happens if client A and client B concurrently try and create a subdoc with the same key? This generally seems like it's an issue with maps since their values are last-write-wins. How could one implement something where two users may concurrently create the same text document at the same time, and you want their edits to converge?
I'm not sure how this can happen. I expect that content is usually only created by a single user. I suspect that you are implementing a problematic pattern. In order to have two users create the same(?) content at the same time, you need coordination between these users. Yjs is coordination-free, so you'd need to implement this yourself (it would be better to avoid this problematic pattern).
I think the other questions have been posted on the discussion forum as well (if they haven't they should be). I feel the chat is not a good place to ask complicated questions. It's hard to keep track. It would be better to post to discuss.yjs.dev instead.
Hi everyone,
I am currently trying to setup my own yjs backend. This backend should fulfil the following three requirements:
Is such a thing or a similar one already implemented? If so, could you provide me with such or a nice documentation? 😀
Hi everyone new to working with YJs, trying to implement yjs with code mirror on a nextjs app. I'm following this https://github.com/yjs/y-codemirror but I get an error each time saying "A Yjs doc connected to room {room name} already exists" .
Which is quite confusing because surely the room has to exist for more than 1 client to connect? Any advice on how to solve this simple bug?
I build a yjs.js file , but it can't work.
{
input: './src/index.js',
output: {
name: 'Y',
file: 'dist/yjs.js',
format: 'iife'
},
external: id => /^lib0\//.test(id)
}
then, i used <script> in html
<script src="js/yjs.js"></script>
there is an error: Uncaught ReferenceError: observable is not defined
so Yjs must depend on Nodejs?