Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Kevin Jahns
    @dmonad
    Hi @alidlorenzo ,
    You are probably asking if any peer can craft malformed data that will lead to issues on the other side.
    Any client can delete data and bring it to an invalid state. But you can probably develop update messages that lead to exponential runtime behavior when applying.
    Another reason why The y-websocket server shouldn't parse the document anymore..
    Léo
    @Miaourt
    Ty for replies !
    I need to find time to try your pretty piece of code, maybe another silly question : is undo-redo possible with subdocuments inside documents ? Say I "undo" the document holding subdocuments, can it rollback changes in a subdocument / invert the deletion of a document, etc etc ?
    Kevin Jahns
    @dmonad
    That is not possible with the current implementation of the Y.UndoManager. Although generally, something like this would be possible.
    Léo
    @Miaourt
    Thanks for your help, kinda starting to understand, Yjs isn't really for "CRDT all the things", it's more like a specialized one for arrays and strings, I am right ? (Tho it would cover lots of usecase)
    I'm kinda thinking of something like roamresearch/remnote/workflowly , where you technically have hundreds (thousands ?) of tiny "documents" sitting in one or more bigger "document", each being a bullet that could be used as parent and then display all the children bullets
    Thus, when working on a very large dataset, it's complicated to load ALL the "bullets", so most must stay on indexeddb/y-providers, yet it would need to keep tracks of all the changes in every bullets and sync them... I'm maybe wrong but having a document for each of the thousands of bullets seems like a big overhead uh ? Let alone syncing them if I do unload them while working on another part of my "database of bullet" ?
    dongtc
    @dongtc
    How to implement comments with yjs and prosemirror, anyone has an idea? use decration or mark?
    Kevin Jahns
    @dmonad

    @Miaourt Yjs is meant to be a "CRDT for all the things". Though I still plan to implement some features that will make certain things easier.

    I don't know how large large in your context is. But if your document grows behind a certain threshold you could organize your bullets using subdocuments. https://docs.yjs.dev/api/subdocuments This would allow you to load bullets asynchronously / on-demand. But Yjs handles very large documents as outlined here: https://blog.kevinjahns.de/are-crdts-suitable-for-shared-editing/

    @dongtc Both would work. If you manage them using decorations you should use relative positions to refer to positions in the document (see docs).
    Florian Wiech
    @florianwiech
    @dmonad Are there any obstacles for merging yjs/y-prosemirror#26 ?
    Kevin Jahns
    @dmonad
    Hey @florianwiech , it was quite a massive change for a simple feature. I refactored the PR and merged it in y-prosemirror@1.0.0.
    Florian Wiech
    @florianwiech
    Hi, just got the notification. Thank you!
    Nandit Mehra
    @nandit123
    hi @dmonad i was using the prosemirror-versions and changed websocket to webrtc as provider there. Now i am trying to create unique rooms by changing the room name, but the peers are taking a lot of time to find each other. How can i fasten this? Also the data of only the room with name space-test is getting persisted when all peers go offline and come back. Any other room, looses its data as soon as all peers go offline. What am i missing?
    sometimes a new peer gets the data when i refresh the browser window on my current window.. strange
    Nandit Mehra
    @nandit123

    i am also getting the following error in console

    1. Uncaught (in promise) TypeError: decoder.arr is undefined decoding.js:239
    2. WebRTC: ICE failed, add a TURN server and see about:webrtc for more details

    on a new peer i get the following error in console as well

    1. Uncaught TypeError: user is undefined yjs.mjs:1941
    Kevin Jahns
    @dmonad

    Hi @nandit123 ,
    Are you using y-indexeddb for offline editing? https://docs.yjs.dev/getting-started/allowing-offline-editing
    I maintain several signaling servers with very low specs that your clients use to find each other. These servers are located in Europe, and the US. It probably takes a bit longer for peers to find each other if they are not in a region with a signaling server. You could set up a a custom signaling server to speed up the signaling process. https://github.com/yjs/y-webrtc/#signaling

    • Uncaught TypeError: user is undefined yjs.mjs:1941
    • Uncaught (in promise) TypeError: decoder.arr is undefined decoding.js:239

    Could you please report an issue with steps to reproduce in https://github.com/yjs/y-webrtc/issues ?

    WebRTC: ICE failed, add a TURN server and see about:webrtc for more details

    It seems you are behind a proxy. WebRTC requires you to be able to connect to other peers directly. This is like BitTorrent (remember when we explicitly needed to forward ports on the router?). The Webrtc spec defines several methods to connect to other peers (without explicitly forwarding ports). The gold standard is to use Triple ICE (basically trying out every possible connection method until something works; which is implemented by simple-peer, the webrtc package that Yjs uses). In the case that no method works (which apparently is the case in your scenario) then the client tries to connect through a TURN server (imagine a dumb server simply forwarding messages). I don't maintain TURN servers because that would be too expensive. You can add your own TURN server or purchase access to TURN servers.

    Nandit Mehra
    @nandit123
    @dmonad thanks for responding, i am now able to understand those error.
    Also everytime on a new browser-window/tab or even refresh i get a new ClientID, is there a direct way to make it static for a peer accessing the document?
    Kevin Jahns
    @dmonad
    Everytime on a new browser-window/tab or even refresh i get a new ClientID, is there a way to make it static for a peer accessing the document?
    The ClientID is used for conflict resolution. So it is important that you understand all the side-effects of retaining a ClientID across sessions. The simple answer is: Yjs is designed to create a new ClientID for every session to avoid sync conflicts. The recommended method to identify users is using the Awareness feature. If you still want to retain a ClientID, you can do so by simply overwriting the ydoc.clientID property. But you must ensure that no other Y.Doc instance is currently holding that ClientID. This is not always possible: A user might open several browser-windows with the same user-account. When two Y.Doc instances with the same ClientID exist, the document might get permanently corrupted without a way to recover. So do this with caution.
    Nigel Gilbert
    @micrology

    I'm trying out the awareness protocol, and either misunderstanding what is supposed to happen, or making a silly mistake with the code. I have two clients, each running the following (this is a slightly simplified version):

    import * as Y from 'yjs';
    import { WebsocketProvider } from 'y-websocket';
    import * as awareness from 'y-protocols/awareness.js';
    const doc = new Y.Doc();
    const wsProvider = new WebsocketProvider('wss://cress.soc.surrey.ac.uk/wss', 'prsm', doc);
    yAwareness = new awareness.Awareness(doc);
    yAwareness.on('change', function () {
            console.log(yAwareness.getStates());
        });
    yAwareness.setLocalState('test', newDate());

    What I see is that, when the setLocalState is executed on each client, the observer reports the change of state of the local client, but never reports the state of the other client (which is what I had understood is the point of the awareness protocol). I also have (not shown) Y.Map and Y.Array types shared between the two clients, and the sharing works as expected, so it is not that there is no communication between the clients, just not the awareness.

    Kevin Jahns
    @dmonad
    Yjs and the awareness protocol can encode everything that is json encodable. A date is not json encodable and hence it probably encodes it as an empty json object.
    Try to get a unix timestamp or a datestring
    I also just finished the awareness tutorial section https://docs.yjs.dev/getting-started/adding-awareness
    anjalikk14
    @anjalikk14

    Hey @aslakhellesoy , you are right - it is not enabled by default. You could enable it by adding an undo-manager and hooking it to the keybindings. I'd also love to get a PR on it :) But probably going to add it in the next few weeks anyway. I have a new client who is using codemirror and there are some things that I want to iron out: e.g. better remote cursor rendering.

    Hey @dmonad was just searching through gitter about undo/redo on yjs. Is this still in the pipeline for you? It looks like it's still commented out in y-codemirror

    (Sorry about pulling up an old thread, that comment was from all the way back in June!)
    Nigel Gilbert
    @micrology
    @dmonad The awareness tutorial is great. And it showed me my error. In the code fragment above, instead of
    yAwareness = new awareness.Awareness(doc);

    it should have been:

    yAwareness = wsProvider.awareness;

    With that change, and with providing an object to setLocalState, it now works. thx

    Kevin Jahns
    @dmonad
    Great! Let me know if you have feedback. There's also an edit-button that you could use to suggest changes.
    3 replies
    Hey @anjalikk14
    I'm currently not, and there is no timeline. My highest priority right now is to get the documentation finished which turned out to be a lot of work. I also maintain lots of other packages, all in my free time. So sorry, I can't do that right now. But you could hook up the undomanager yourself and test out if there are any issues. It currently doesn't handle restoring selections right now, which is something I'm planning to implement (when hitting undo, it should restore the selection before the change. This is useful, for example, when selecting some text , then deleting it, and then undoing that deletion - you expect that the selection is restored)
    Nandit Mehra
    @nandit123
    hey @dmonad i was using y-webrtc as provider, and wanted to know how well does the encryption works. We can mention password for room, but how reliable is this password protection and encryption type.
    Also is there a way to change the password of a pre-existing room ?
    anjalikk14
    @anjalikk14
    Thanks for the quick response @dmonad
    image.png
    I'll toy around with the UndoManager, my initial experiments didn't go so great but I might be doing something wrong.
    O the image copied in above the text thats odd
    Specifically it looks like undo works(ish), but redo stops working after the first change is redone
    so for example, if I type:
    "aa" and then cntrl-z, cntrl-z -- it does the right thing.
    But if i then try: cntrl-y, cntrl-y -- I only get "a" back
    More digging required! (but if you have any hints, much appreciated!)
    Kevin Jahns
    @dmonad
    Hey @nandit123 y-webrtc uses web technology to encrypt signaling data. y-webrtc depends on signaling servers to find other peers. If encryption is enabled, the clients encrypt all messages using that "password" to exchange signaling data. This prevents man-in-the-middle attacks even if the signaling server is compromised. WebRTC connections are always encrypted (it's baked into the standard). You can see the implementation of the encryption here:- https://github.com/yjs/y-webrtc/blob/master/src/crypto.js In hindsight I should have used longer keys. I got the code for the encryption from mdn.
    @anjalikk14 No hints unforatunately. It looks correct. But if you can reproduce the issues please open a ticket in y-codemirror and I will fix the issue.
    Nandit Mehra
    @nandit123
    Thanks @dmonad !!! as asked in my previous question, do you think if there is a way to change password without effecting the content of crdt document?
    Kevin Jahns
    @dmonad
    You can just use a different password. And all clients using the same password will sync up. Clients with different passwords can't communicate. There is no explicit method to change the password though - so you need all clients to agree on something new at the same time
    NovelPad
    @novel_pad_twitter
    This might be a silly question, but I'm having some trouble setting a value on a Y.Map object. Any ideas why the following logs "undefined"?
        const e = 'a';
        const element = new Y.Map();
        console.log('setting text to', e);
        element.set('text', new Y.Text(e));
        console.log(element.get('text'));
    (Pardon the horrible variable names. This is just an initial attempt to use yjs for a simple use case.)
    NovelPad
    @novel_pad_twitter
    I'm looking through the slate-yjs repository, and as far as I can tell it's assuming the YArrayEvent class's changes delta is a list of Y.Map instances, when it's actually coming back as a list of strings. It feels like I'm missing a simple concept :/.
    NovelPad
    @novel_pad_twitter
    Figured out both issues. Thanks for the excellent library!
    Kevin Jahns
    @dmonad
    Okay great!
    I also wanted you to this ticket: yjs/yjs#207 I haven't decided if I want to fix the described behavior. But it really seems inconsistent..
    NovelPad
    @novel_pad_twitter
    Took a while of reading through the source code, but once I realized the Yjs data-type classes were inherently associated with a parent document, everything clicked and I was able to finish my POC. Your answer in that ticket confirms it, so I think I'm finally on the right path. Thanks for the quick response!