Open kwshi opened 2 years ago
Huh, that's very odd, I'm not sure what could be causing this. The process management code needs a serious rewrite, I suspect it has a number of potential race conditions because I wrote my own thing instead of using an existing container runtime like Kubernetes.
Sometimes, the REPL doesn't print output that it's supposed to print, and the program prematurely ends before all output has been sent. Example-- the following program prints 0 through 9; when this program is run, most of the times the correct output is shown but sometimes, seemingly at random, the output cuts off early:
Inspecting the websocket message log shows the following exchange:
{"event":"runCode","code":"#include <iostream>\n\nint main() {\n for (int i = 0; i < 10; ++i) {\n std::cout << i << std::endl;\n }\n}\n"}
{"event":"terminalClear"}
{"event":"terminalOutput","output":"0\r\n1\r\n2\r\n3\r\n"}
{"event":"serviceFailed","service":"terminal","error":"Exited with status 0","code":0}
{"event":"terminalInput","input":"\r"}
So it seems like the missing output is not transmitted at all by the server, rather than it being hidden by some UI-level bug.
(Another example, in which the last output line
hello
is dropped:){"event":"runCode","code":"#include <iostream>\n\nint main() {\n for (int i = 0; i < 5; ++i) {\n std::cout << i << std::endl;\n }\n\n int n;\n std::cin >> n;\n\n std::cout << \"hello \" << n << std::endl;\n}\n"}
{"event":"terminalClear"}
{"event":"terminalOutput","output":"0\r\n1\r\n2\r\n3\r\n4\r\n"}
{"event":"terminalInput","input":"7"}
{"event":"terminalOutput","output":"7"}
(down) {"event":"serviceFailed","service":"terminal","error":"Exited with status 0","code":0}