Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node-runtime-worker-thread): remove function properties before serializing errors COMPASS-5919 #1762

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Nov 29, 2023

The structured cloning algorithm used by postMessage doesn't support functions. When invalid syntax is fed into the runtime-worker-thread for evaluation, mongosh returns a BabelParseError, which has a clone() method. This method causes the serialization of the error to fail and the incorrect error to be reported to Compass (see COMPASS-5919).

This fix removes all function properties from Errors before serialization.

Below I've attached a screenshot showing this fix with a local build of Compass. The screenshot shows the same reproduction from COMPASS-5919, except that the syntax error is properly returned to Compass and rendered.
Screenshot 2023-11-29 at 2 43 41 PM

@baileympearson
Copy link
Contributor Author

CI failures seem unrelated, I'm putting the PR up for review

@baileympearson baileympearson marked this pull request as ready for review November 29, 2023 21:45
@baileympearson baileympearson changed the title fix(node-runtime-worker-thread): remove function properties before structured cloning errors COMPASS-5919 fix(node-runtime-worker-thread): remove function properties before serializing errors COMPASS-5919 Nov 30, 2023
@baileympearson baileympearson merged commit 010161a into main Nov 30, 2023
61 checks passed
@baileympearson baileympearson deleted the COMPASS-5919 branch November 30, 2023 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants