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 cloning Util.inherit() subclassed errors #401

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

kanongil
Copy link
Contributor

@kanongil kanongil commented Nov 14, 2024

This should fix the issue in #400.

Util.inherits() (essentially Object.setPrototypeOf() on prototype properties) subclassed errors somehow trigger different structuredClone() cloning logic than regular ES6 subclassed errors. This seems to be a fallout of the issue in nodejs/node#4179, which found that the prototype chain is not applied.

The fix is to detect these (using a failing Error.isPrototypeOf(proto.constructor)), and fallback to the old cloning logic. Incidentally, it seems that custom errors subclassed using Util.inherits() continue to preserve the stack using the old logic.

@kanongil kanongil added the bug Bug or defect label Nov 14, 2024
@Marsup Marsup merged commit a36702e into hapijs:next Nov 14, 2024
12 checks passed
@Marsup Marsup added this to the 11.0.7 milestone Nov 14, 2024
@Marsup Marsup self-assigned this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or defect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants