Skip to content

Commit

Permalink
fix(3.4.1): convert Error class to object in worker (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunSHamilton authored Mar 11, 2024
2 parents a94f765 + 0737996 commit 13746cf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .freeCodeCamp/tooling/tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion .freeCodeCamp/tooling/tests/test-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
6 changes: 6 additions & 0 deletions docs/src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 13746cf

Please sign in to comment.