-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code evaluations are duplicated #189
Comments
I have noticed this some time as well, where code was posted twice in the |
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. |
It's definitely happening here all the time, with SC REPL (both users are getting double evaluations of everything). |
Can confirm that I'm getting this error too! It really makes things weird with my setup. SC is getting confused about it. |
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 I have not been able to find how this works in the I'm also wondering if you could explain how you develop for Flok packages? Because only the web package has an option to run |
@munshkr, a little bump here too, if you find some time :) |
that might be the same issue as this: #299 ? |
This bug also happens with Sardine and other languages I have tried. Only appears when multiple people join the session though. Hard to reproduce when playing/experimenting alone. |
Could this potentially be because of a sync issue where the contents of an editor get duplicated. I've seen times where you get the same code listed out many times. It's sometimes hard to notice it because the duplicated code is way below your currently visible code. Might be a more general YJS issue. |
while skimming the code, i've noticed the flok/packages/session/lib/session.ts Line 373 in 39a05e5
|
I tried removing the line: flok/packages/session/lib/session.ts Line 373 in 39a05e5
To test what happens if fromMe===false . But the volume stays the same.
I also duplicated this line 4 times to simulate message duplication. No double-volume:
And also this one 4 times, still no double-volume (although Bubo suggests it's a problem with all langs, not just Strudel):
I was starting to look into how Flok passes new code to Strudel, and I'm still puzzled how Strudel knows which doc to update, but then I read Bubo's comment... flok/packages/web/src/lib/strudel-wrapper.ts Line 153 in 39a05e5
TodePond's suggestion is what I'd look at next, because:
Not sure why the problem "corrects itself" later though, but I haven't dived into the server code yet. |
The server appears to be a simple "pubsub" so I don't expect we'll find the bug there.. TodePond's theory is still my best bet: that code gets duplicated somehow; If everybody hears the same "volume-doubling incident" at the same time then I'd also expect to see code duplication in the messages that the server passes around. This should be visible in the network tab ("pubsub" WebSocket traffic). Unfortunately, browsers don't record traffic until you ask them to so you'd have to start recording up-front and "wait" until the problem happens... If the volume-doubling is only heard by one person then I'd expect the network messages to look normal, while duplication would be seen in the Strudel/etc evals (if we logged them). Whether it's heard-by-one or heard-by-everybody could be found out if we have multiple independent recordings of a session where it occurs? (or, someone could write We could also add temporary debug code like console.log()s or store info in |
Got a screenshot of "code-doubling" yesterday: |
I think one thing we may as well do is bump yjs to the latest version. It gets regular fixes. Not confidence it would help but no harm I dont think |
Here's me bumping yjs |
where does this happen? so its visible in the editor? |
Interesting, I've never seen code actually doubling in the editor. Just the OSC-message for the repl being send twice (or more than 2x if more people are active in the session). |
Yes. Here it's visible in the video: |
interesting, i haven't had that before.. here's a moment where the volume doubles, but the code stays intact: https://www.youtube.com/watch?v=jdFSmr3koXg&t=3470s (doubling is gone after re-eval). as reported in #299 |
recording the next session from 2 machines is a good idea, as we could see if the doubling is synced or not |
Seems like two separate issues. I've definitely seen the "doubled code" issue a lot. Never noticed the "double eval" issue |
I agree, I think that we are chasing two separate issues. I've experienced the double eval but never the doubled code (the opposite compared to @TodePond). The former might be a bug in the backend while the latter appears to be some CodeMirror related issue. I've experienced line/code duplication in the past while dealing with some editor plugins. |
extensive logging seems like the only way to identify the issue. we need to log all server messages then play and see if we hit the bug. probably best to add logging (to a file) on a seperate branch and run locally? edit: combined with a recording, we can pinpoint when it happens |
I wrote a tiny "pubsub logger" script for flok. Requires (edit: it prints both the json message, but also the code blob itself for readability if present) import fs from 'fs';
if (process.argv.length !== 3) {
console.error(`Usage: ${process.argv[1]} <session name>`);
process.exit(1);
}
const session_name = process.argv[2];
import websocket from 'websocket'; // npm install websocket
const client = new websocket.client();
client.on("connect", (conn) => {
conn.sendUTF(JSON.stringify({
type:"state",
payload:{topics:[`session:${session_name}:target:strudel:eval`]}
}));
conn.on("message", (msg) => {
msg = JSON.parse(msg.utf8Data);
let code = msg.payload && msg.payload.message && msg.payload.message.body || "";
const SEP="==========================\n";
const logmsg = SEP+Date()+":\n"+JSON.stringify(msg)+"\n"+code+"\n"+SEP+"\n";
console.info(logmsg);
fs.appendFileSync(`flok.${session_name}.log`, logmsg)
});
});
client.connect("wss://flok.cc/pubsub"); |
No description provided.
The text was updated successfully, but these errors were encountered: