improve copilot + fix minor bugs

This commit is contained in:
Ishaan Dey
2024-05-26 18:04:43 -07:00
parent fbb98ac3b0
commit 6285a68102
7 changed files with 57 additions and 47 deletions

View File

@ -17,8 +17,6 @@ import {
getSandboxFiles,
renameFile,
saveFile,
stopServer,
testDescribe,
} from "./utils";
import { IDisposable, IPty, spawn } from "node-pty";
import {
@ -453,24 +451,22 @@ io.on("connection", async (socket) => {
);
}
const sockets = await io.fetchSockets();
if (inactivityTimeout) {
clearTimeout(inactivityTimeout);
}
if (sockets.length === 0) {
console.log("STARTING TIMER");
inactivityTimeout = setTimeout(() => {
io.fetchSockets().then(async (sockets) => {
if (sockets.length === 0) {
console.log("Closing server due to inactivity.");
const res = await stopServer(data.sandboxId);
console.log("Server stopped", res);
}
});
}, 20000);
} else {
console.log("number of sockets", sockets.length);
}
// const sockets = await io.fetchSockets();
// if (inactivityTimeout) {
// clearTimeout(inactivityTimeout);
// }
// if (sockets.length === 0) {
// console.log("STARTING TIMER");
// inactivityTimeout = setTimeout(() => {
// io.fetchSockets().then(async (sockets) => {
// if (sockets.length === 0) {
// console.log("Server stopped", res);
// }
// });
// }, 20000);
// } else {
// console.log("number of sockets", sockets.length);
// }
});
});