fix(judge): modify timeout handling logic to resolve on time limit exceeded

This commit is contained in:
cfngc4594 2025-03-03 02:29:55 +08:00
parent 03f3d9682a
commit 11c2e2c317

View File

@ -190,7 +190,7 @@ async function run(container: Docker.Container, fileName: string, timeLimit?: nu
}); });
// Start the exec stream // Start the exec stream
runExec.start({}, async (error, stream) => { runExec.start({}, (error, stream) => {
if (error || !stream) { if (error || !stream) {
return reject({ output: "System Error", exitCode: ExitCode.SE }); return reject({ output: "System Error", exitCode: ExitCode.SE });
} }
@ -198,9 +198,7 @@ async function run(container: Docker.Container, fileName: string, timeLimit?: nu
docker.modem.demuxStream(stream, stdoutStream, stderrStream); docker.modem.demuxStream(stream, stdoutStream, stderrStream);
// Timeout mechanism // Timeout mechanism
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(async () => {
// Timeout reached, kill the container
container.kill();
resolve({ resolve({
output: "Time Limit Exceeded", output: "Time Limit Exceeded",
exitCode: ExitCode.TLE, exitCode: ExitCode.TLE,