Skip to content

fix: handle DOMException in Boom constructor #307

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jpage-godaddy
Copy link

@jpage-godaddy jpage-godaddy commented Jun 4, 2025

DOMException instances have getters that require correct 'this' context. Hoek.clone() creates copies that lose the internal structure needed for these getters to work, causing "Value of 'this' must be of DOMException" errors. Extract message and name properties before cloning to avoid this issue.

Example stack trace error we were getting:

TypeError: Value of "this" must be of DOMException
    at throwInvalidThisError (node:internal/per_context/domexception:17:15)
    at get message [as message] (node:internal/per_context/domexception:90:7)
    at internals.initialize (/.../@hapi/boom/lib/index.js:427:14)
    at exports.boomify (/.../@hapi/boom/lib/index.js:126:26)
    at new exports.Boom (/.../@hapi/boom/lib/index.js:74:28)
    at internals.serverError (/.../@hapi/boom/lib/index.js:468:12)
    at exports.badImplementation (/.../@hapi/boom/lib/index.js:400:27)
    at ...
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_INVALID_THIS'
}

DOMException instances have getters that require correct 'this' context.
Hoek.clone() creates copies that lose the internal structure needed for
these getters to work, causing "Value of 'this' must be of DOMException"
errors. Extract message and name properties before cloning to avoid this issue.
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.

1 participant