mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
system: do not let a failed console request look like an empty answer
fetch() does not throw on 4xx, so a request that came back 401 after the session had timed out reached the same line as a successful one: the window showed the prompt and nothing under it, and the input was cleared as if the command had run. The session lasts 200 seconds, so leaving the tab open is enough to hit it. A 401 now goes to the login page instead. The transcript also gets a trailing newline when the answer lacks one, so the next prompt does not run into the last line of output, and it is capped so a long session does not keep growing the node.
This commit is contained in:
1 parent
f23d840cee
commit
a259587bf9
1 file changed
+10
-1
+10
-1
@@ -43,7 +43,16 @@ async function cmdSub() {
|
||||
method: 'POST',
|
||||
body: cmd
|
||||
});
|
||||
out.textContent += "> " + cmd + "\n" + await response.text();
|
||||
if (response.status == 401) {
|
||||
window.location.href = 'login.html';
|
||||
return;
|
||||
}
|
||||
let text = await response.text();
|
||||
if (text != "" && !text.endsWith("\n"))
|
||||
text += "\n";
|
||||
if (out.textContent.length > 20000)
|
||||
out.textContent = out.textContent.slice(-16000);
|
||||
out.textContent += "> " + cmd + "\n" + text;
|
||||
out.scrollTop = out.scrollHeight;
|
||||
input.value = "";
|
||||
} catch(err) {
|
||||
|
||||
Reference in new issue
Block a user