Merge 'sim/aws: fix sim timeout handling' from Jussi Saurio

code was trying to consume the same readablestream twice: once in the
timeouter's catch block, and a second time in the body of the try block
before postGithubIssue() could run.

Closes #1658
This commit is contained in:
Jussi Saurio
2025-06-04 09:38:31 +03:00

View File

@@ -77,28 +77,9 @@ const run = async (seed: string, bin: string, args: string[]) => {
});
const timeout = timeouter(PER_RUN_TIMEOUT_SECONDS, runNumber);
timeout.catch(async (err) => {
if (err instanceof TimeoutError) {
console.log(`Timeout on seed ${seed}, exiting...`);
proc.kill();
const stdout = await new Response(proc.stdout).text();
const stderr = await new Response(proc.stderr).text();
const output = stdout + '\n' + stderr;
const seedForGithubIssue = seed;
const lastLines = output.split('\n').slice(-100).join('\n');
console.log(`Simulator seed: ${seedForGithubIssue}`);
await github.postGitHubIssue({
type: "timeout",
seed: seedForGithubIssue,
command: args.join(" "),
output: lastLines,
});
process.exit(0);
}
});
try {
const exitCode = await proc.exited;
const exitCode = await Promise.race([proc.exited, timeout]);
const stdout = await new Response(proc.stdout).text();
const stderr = await new Response(proc.stderr).text();
@@ -138,7 +119,24 @@ const run = async (seed: string, bin: string, args: string[]) => {
}
}
} catch (err) {
throw err;
if (err instanceof TimeoutError) {
console.log(`Timeout on seed ${seed}, posting to Github...`);
proc.kill();
const stdout = await new Response(proc.stdout).text();
const stderr = await new Response(proc.stderr).text();
const output = stdout + '\n' + stderr;
const seedForGithubIssue = seed;
const lastLines = output.split('\n').slice(-100).join('\n');
console.log(`Simulator seed: ${seedForGithubIssue}`);
await github.postGitHubIssue({
type: "timeout",
seed: seedForGithubIssue,
command: args.join(" "),
output: lastLines,
});
} else {
throw err;
}
} finally {
// @ts-ignore
timeout.clear();