[sandbox] Terminate after 30 seconds

This commit is contained in:
orosmatthew 2023-05-09 17:19:19 -04:00
parent 83b5d75ed1
commit 97b8f6028a

View File

@ -33,8 +33,22 @@ export async function runJava(
child.stdin.write(input);
child.stdin.end();
let resolved = false;
child.on('close', () => {
if (!resolved) {
resolved = true;
resolve(outputBuffer);
}
});
setTimeout(() => {
if (!resolved) {
console.log('30 seconds reached, killing process');
resolved = true;
child.kill('SIGKILL');
resolve(outputBuffer + '\n[Timeout after 30 seconds]');
}
}, 30000);
});
}