From 0737996907a098b3264d60c88ceb5d0aa1719650 Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Mon, 11 Mar 2024 08:58:45 +0200 Subject: [PATCH] fix(3.4.1): convert Error class to object in worker --- .freeCodeCamp/tooling/tests/main.js | 6 +++--- .freeCodeCamp/tooling/tests/test-worker.js | 4 +++- docs/src/CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.freeCodeCamp/tooling/tests/main.js b/.freeCodeCamp/tooling/tests/main.js index d2f09b36..db7c135c 100644 --- a/.freeCodeCamp/tooling/tests/main.js +++ b/.freeCodeCamp/tooling/tests/main.js @@ -154,9 +154,9 @@ export async function runTests(ws, projectDashedName) { logover.error(`Test #${testId}:`, error); } - if (error.text?.message) { - const assertionTranslation = await t(error.text.message, {}); - error.text.message = assertionTranslation || error.text.message; + if (error.message) { + const assertionTranslation = await t(error.message, {}); + error.message = assertionTranslation || error.message; } const consoleError = { diff --git a/.freeCodeCamp/tooling/tests/test-worker.js b/.freeCodeCamp/tooling/tests/test-worker.js index 15fe7d4d..88e12a87 100644 --- a/.freeCodeCamp/tooling/tests/test-worker.js +++ b/.freeCodeCamp/tooling/tests/test-worker.js @@ -30,7 +30,9 @@ parentPort.on('message', async ({ testCode, testId }) => { passed = true; } catch (e) { error = {}; - error.text = e; + Object.getOwnPropertyNames(e).forEach(key => { + error[key] = e[key]; + }); // Cannot pass `e` "as is", because classes cannot be passed between threads error.type = e instanceof AssertionError ? 'AssertionError' : 'Error'; } diff --git a/docs/src/CHANGELOG.md b/docs/src/CHANGELOG.md index a8b403ae..4d18a508 100644 --- a/docs/src/CHANGELOG.md +++ b/docs/src/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [3.4.1] - 2024-03-11 + +### Fix + +- Convert `Error` class to object in worker before sending to parent + ## [3.4.0] - 2024-03-05 ### Add diff --git a/package-lock.json b/package-lock.json index d0b8b627..e722f8ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@freecodecamp/freecodecamp-os", - "version": "3.4.0", + "version": "3.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@freecodecamp/freecodecamp-os", - "version": "3.4.0", + "version": "3.4.1", "dependencies": { "chai": "4.4.1", "chokidar": "3.6.0", diff --git a/package.json b/package.json index 51c504f8..b4be6bb4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@freecodecamp/freecodecamp-os", "author": "freeCodeCamp", - "version": "3.4.0", + "version": "3.4.1", "description": "Package used for freeCodeCamp projects with the freeCodeCamp Courses VSCode extension", "scripts": { "build:client": "NODE_ENV=production webpack --config ./.freeCodeCamp/webpack.config.cjs",