Skip to content

Commit c8a91aa

Browse files
committed
Fix many bugs with timeout from recent commits
1 parent 59adae5 commit c8a91aa

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/utils/runtime.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export class Runnable {
1616
private _timedOut = false;
1717
private _exitCode: number | null = null;
1818

19-
run(command: string, timeout: number, cwd?: string, ...args: string[]) {
19+
run(command: string, timeout?: number, cwd?: string, ...args: string[]) {
2020
// FIXME: Simplify TL to check a flag once https://github.com/nodejs/node/pull/51608 lands
2121

22-
const timeoutSignal = AbortSignal.timeout(timeout);
22+
const timeoutSignal = timeout ? AbortSignal.timeout(timeout) : undefined;
2323
this._process = child_process.spawn(command, args, {
2424
cwd,
2525
signal: timeoutSignal,
@@ -37,7 +37,7 @@ export class Runnable {
3737
this._endTime = performance.now();
3838
this._signal = signal;
3939
this._exitCode = code;
40-
this._timedOut = timeoutSignal.aborted;
40+
this._timedOut = timeoutSignal?.aborted ?? false;
4141
resolve();
4242
});
4343
});
@@ -115,7 +115,12 @@ export async function compile(
115115
context.subscriptions.push(compilationStatusItem);
116116

117117
const process = new Runnable();
118-
process.run(resolvedArgs[0], 0, undefined, ...resolvedArgs.slice(1));
118+
process.run(
119+
resolvedArgs[0],
120+
undefined,
121+
undefined,
122+
...resolvedArgs.slice(1),
123+
);
119124

120125
let err = '';
121126
process.process?.stderr.on('data', (data: string) => {

src/views/judge/provider/JudgeViewProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export default class extends BaseViewProvider<ProviderMessage, WebviewMessage> {
467467
testcase.stdout.reset();
468468
testcase.process.run(
469469
resolvedArgs[0],
470-
newTestcase ? 0 : this._timeLimit,
470+
newTestcase ? undefined : this._timeLimit,
471471
cwd,
472472
...resolvedArgs.slice(1),
473473
);

0 commit comments

Comments
 (0)