Skip to content

Commit

Permalink
fix: calling async function without await
Browse files Browse the repository at this point in the history
  • Loading branch information
dvirtz committed Aug 8, 2021
1 parent e992d1b commit fb9285f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions packages/reveal-test/dist/reveal-test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ const compile = async (info, retryOptions = {}) => {
const failureMismatch = (output) => {
return new compilerExplorerDirectives.CompileError(-1, error(`should have failed with '${info.failReason}'${output.length > 0 ? `\nactual output is:\n${output}` : ''}`));
};
const resultPromise = compilerExplorerDirectives.compile(info, retryOptions);
if (info.failReason) {
try {
const result = await resultPromise;
const result = await compilerExplorerDirectives.compile(info, retryOptions);
throw failureMismatch(result);
} catch (err) {
if (!err.message.includes(info.failReason)) {
Expand All @@ -77,7 +76,7 @@ const compile = async (info, retryOptions = {}) => {
} else {
const result = await (async () => {
try {
return await resultPromise;
return await compilerExplorerDirectives.compile(info, retryOptions);
} catch (err) {
const code = err.hasOwnProperty('code') ? err.code : -2;
throw new compilerExplorerDirectives.CompileError(err.code, error(err.message));
Expand Down
2 changes: 1 addition & 1 deletion packages/reveal-test/dist/reveal-test.cjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions packages/reveal-test/src/reveal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ const compile = async (info, retryOptions = {}) => {
const failureMismatch = (output) => {
return new CompileError(-1, error(`should have failed with '${info.failReason}'${output.length > 0 ? `\nactual output is:\n${output}` : ''}`));
};
const resultPromise = origCompile(info, retryOptions)
if (info.failReason) {
try {
const result = await resultPromise;
const result = await origCompile(info, retryOptions);
throw failureMismatch(result);
} catch (err) {
if (!err.message.includes(info.failReason)) {
Expand All @@ -71,7 +70,7 @@ const compile = async (info, retryOptions = {}) => {
} else {
const result = await (async () => {
try {
return await resultPromise;
return await origCompile(info, retryOptions);
} catch (err) {
const code = err.hasOwnProperty('code') ? err.code : -2;
throw new CompileError(err.code, error(err.message));
Expand Down

0 comments on commit fb9285f

Please sign in to comment.