munshkr / flok

Web-based P2P collaborative editor for live coding sounds and images
https://flok.cc
GNU General Public License v3.0
257 stars 39 forks source link

Code evaluations are duplicated #189

Open munshkr opened 9 months ago

tmhglnd commented 9 months ago

I have noticed this some time as well, where code was posted twice in the flok-repl when I just evaluated once. Don't have any specific steps for reproducing currently, also not sure if it still happened lately. I'll keep an eye out!

munshkr commented 9 months ago

Yes, this still happens.. I think I know what's the problem, it's your own message that gets back at you from the server, and evaluates it (thinking it was from some other user). I need to filter your own messages correctly.

totalgee commented 5 months ago

It's definitely happening here all the time, with SC REPL (both users are getting double evaluations of everything).

Bubobubobubobubo commented 5 months ago

Can confirm that I'm getting this error too! It really makes things weird with my setup. SC is getting confused about it.

tmhglnd commented 3 months ago

I tried to look into this issue but I'm having a hard time and no idea where to look to try and fix this. I've been searching through the code for a while to find from where the actually evaluating is "emitted" to the repl. Sadly there is too little documentation in the code for me to figure out how this actually works. Can you give some pointers/explanation where this can be fixed? Then I'm happy to help, because I like this issue to be resolved.

I've been able to trace that the BaseREPL receives a message with { docID, body, user, mode, from, to } via the pubSubSubscribe.

I have not been able to find how this works in the PubSub class though and also not how this message is send from the web session to the server.

I'm also wondering if you could explain how you develop for Flok packages? Because only the web package has an option to run npm run dev (if I see correctly), how can I work on the Repl and other packages without having to run npm run build every time? Maybe I'm missing something basic here about how Typescript works (for example I see there is a debugModule(), but I also have no idea how to work with that and wasn't able to find documentation about it so far), I usually install some package like watchify to be able to develop without building every time, but I don't see that (or something similar) listed in the dependencies.