Merge pull request 'fix: add timeout handling for script execution in Vm class' (#14) from limitingQueryExrcutionTime into develop
All checks were successful
Deploy to Testing Server / Deploy to Testing Environment (push) Successful in 27s
All checks were successful
Deploy to Testing Server / Deploy to Testing Environment (push) Successful in 27s
Reviewed-on: http://192.168.0.16:3000/lborv/few-line-engine/pulls/14 Reviewed-by: jana <comite11@inbox.lv>
This commit is contained in:
@ -172,16 +172,20 @@ export class Vm {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const compiledScript = await this.isolate.compileScript(scriptWithResult);
|
const compiledScript = await this.isolate.compileScript(scriptWithResult);
|
||||||
|
let timer = 0n;
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (
|
if (
|
||||||
this.isolate.cpuTime > this.cpuTimeLimit ||
|
this.isolate.cpuTime > this.cpuTimeLimit ||
|
||||||
this.isolate.wallTime > this.timeLimit
|
this.isolate.wallTime > this.timeLimit ||
|
||||||
|
timer > this.timeLimit
|
||||||
) {
|
) {
|
||||||
this.isolate.dispose();
|
this.isolate.dispose();
|
||||||
|
|
||||||
rejectPromise(new Error("Script execution timed out"));
|
rejectPromise(new Error("Script execution timed out"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer += 500000n;
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
compiledScript.run(this.context);
|
compiledScript.run(this.context);
|
||||||
|
|||||||
Reference in New Issue
Block a user