From 2262618c528fce939f5716e77b9235e43ba339ad Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sun, 6 Mar 2022 17:24:28 +0200 Subject: [PATCH 1/2] Don't start run stage if compile stage errored --- api/src/job.js | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/api/src/job.js b/api/src/job.js index 9b057e6..60c22ff 100644 --- a/api/src/job.js +++ b/api/src/job.js @@ -230,6 +230,7 @@ class Job { this.logger.debug('Compiling'); let compile; + let compile_errored = false; if (this.runtime.compiled) { compile = await this.safe_call( @@ -238,16 +239,20 @@ class Job { this.timeouts.compile, this.memory_limits.compile ); + compile_errored = compile.code !== 0; } - this.logger.debug('Running'); + let run; + if (!compile_errored) { + this.logger.debug('Running'); - const run = await this.safe_call( - this.runtime.run, - [code_files[0].name, ...this.args], - this.timeouts.run, - this.memory_limits.run - ); + run = await this.safe_call( + this.runtime.run, + [code_files[0].name, ...this.args], + this.timeouts.run, + this.memory_limits.run + ); + } this.state = job_states.EXECUTED; @@ -273,6 +278,7 @@ class Job { const code_files = this.files.filter(file => file.encoding == 'utf8'); + let compile_errored = false; if (this.runtime.compiled) { eventBus.emit('stage', 'compile'); const { error, code, signal } = await this.safe_call( @@ -284,19 +290,22 @@ class Job { ); eventBus.emit('exit', 'compile', { error, code, signal }); + compile_errored = code !== 0; } - this.logger.debug('Running'); - eventBus.emit('stage', 'run'); - const { error, code, signal } = await this.safe_call( - this.runtime.run, - [code_files[0].name, ...this.args], - this.timeouts.run, - this.memory_limits.run, - eventBus - ); + if (!compile_errored) { + this.logger.debug('Running'); + eventBus.emit('stage', 'run'); + const { error, code, signal } = await this.safe_call( + this.runtime.run, + [code_files[0].name, ...this.args], + this.timeouts.run, + this.memory_limits.run, + eventBus + ); - eventBus.emit('exit', 'run', { error, code, signal }); + eventBus.emit('exit', 'run', { error, code, signal }); + } this.state = job_states.EXECUTED; } From b381271ba940f3a60a760b45a04e256e2c3c1db6 Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Mon, 2 May 2022 13:25:46 +0200 Subject: [PATCH 2/2] Add backward compatibility in v2.js Set run property to compile if it doesn't exist in v2.js --- api/src/api/v2.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/src/api/v2.js b/api/src/api/v2.js index e95382a..ac1269e 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -264,7 +264,11 @@ router.post('/execute', async (req, res) => { await job.prime(); - const result = await job.execute(); + let result = await job.execute(); + // Backward compatibility when the run stage is not started + if (result.run === undefined) { + result.run = result.compile; + } await job.cleanup();