Skip to content

Commit

Permalink
fix: variable undefined turns to internal server error (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik committed Dec 19, 2023
2 parents 6160db5 + 58707de commit b004f4c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/api/src/app/shared/services/sandbox/Sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,19 @@ export class Sandbox {
fs.writeFileSync(standardOutputPath, '');
fs.writeFileSync(standardErrorPath, '');

return new Promise((resolve, reject) => {
return new Promise((resolve) => {
const process = exec(cmd, async (error, stdout: string | PromiseLike<string>, stderr) => {
if (stdout) {
fs.appendFileSync(standardOutputPath, await stdout);
}

if (error) {
reject(error);
fs.appendFileSync(standardErrorPath, stderr);
resolve({ verdict: EngineResponseStatusEnum.ERROR });

return;
}

if (stdout) {
fs.appendFileSync(standardOutputPath, await stdout);
}

if (stderr) {
fs.appendFileSync(standardErrorPath, stderr);
}
Expand Down

0 comments on commit b004f4c

Please sign in to comment.