fix(client): execute web workers concurrently

This commit is contained in:
Valeriy S
2019-03-14 12:08:15 +03:00
committed by mrugesh mohapatra
parent e8f5b54d63
commit 845b966bda
4 changed files with 134 additions and 91 deletions

View File

@ -333,13 +333,13 @@ async function createTestRunnerForJSChallenge({ files }, solution) {
const { build, sources } = await buildJSChallenge({ files });
const code = sources && 'index' in sources ? sources['index'] : '';
const testWorker = createWorker('test-evaluator');
const testWorker = createWorker('test-evaluator', { terminateWorker: true });
return async ({ text, testString }) => {
try {
const { pass, err } = await testWorker.execute(
{ testString, build, code, sources },
5000
);
).done;
if (!pass) {
throw new AssertionError(`${text}\n${err.message}`);
}
@ -348,8 +348,6 @@ async function createTestRunnerForJSChallenge({ files }, solution) {
? `${text}\n${err}`
: (err.message = `${text}
${err.message}`);
} finally {
testWorker.killWorker();
}
};
}