diff --git a/.freeCodeCamp/tooling/tests/main.js b/.freeCodeCamp/tooling/tests/main.js index db7c135c..79b996ed 100644 --- a/.freeCodeCamp/tooling/tests/main.js +++ b/.freeCodeCamp/tooling/tests/main.js @@ -84,7 +84,9 @@ export async function runTests(ws, projectDashedName) { WORKER_POOL.push(worker); // When result is received back from worker, update the client state + worker.on('error', workerError); worker.on('message', workerMessage); + worker.on('messageerror', workerError); worker.stdout.on('data', data => { logover.debug(`Blocking Worker:`, data.toString()); }); @@ -121,7 +123,9 @@ export async function runTests(ws, projectDashedName) { WORKER_POOL.push(worker); // When result is received back from worker, update the client state + worker.on('error', workerError); worker.on('message', workerMessage); + worker.on('messageerror', workerError); worker.stdout.on('data', data => { logover.debug(`Worker-${i}:`, data.toString()); }); @@ -176,6 +180,10 @@ export async function runTests(ws, projectDashedName) { afterAll }); } + + async function workerError(error) { + logover.error(`Worker Error:`, error); + } } catch (e) { logover.error('Test Error: '); logover.error(e); diff --git a/self/curriculum/locales/english/build-x-using-y.md b/self/curriculum/locales/english/build-x-using-y.md index 8e4e96ab..eb7ae2cf 100644 --- a/self/curriculum/locales/english/build-x-using-y.md +++ b/self/curriculum/locales/english/build-x-using-y.md @@ -51,6 +51,20 @@ await new Promise(resolve => setTimeout(resolve, 1000)); assert.equal(__helpers.testDynamicHelper(), 'Helper success!'); ``` +Testing if a worker error causes the server to crash. + +```js +// 3 +try { + fetch('http://localhost:3123'); +} catch (e) { + console.log('------test------'); + console.log(e); + console.log('------test------'); + assert.equal(e.message, 'Failed to fetch'); +} +``` + ### --before-each-- ```js