You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
defining Object.prototype.then causes esm loader to throw an error #45035
How often does it reproduce? Is there a required condition?
N/A
What is the expected behavior?
It would be great not to throw an error.
What do you see instead?
If you import/dynamically import something before setting Object.prototype.then, you get this error:
node:internal/modules/esm/loader:527
.then(({ module }) => module.getNamespace());
^
TypeError: Cannot read properties of undefined (reading 'getNamespace')
at node:internal/modules/esm/loader:527:38
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
Node.js v18.11.0
however if you use a dynamic import after it, you get a different error:
node:internal/errors:484
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected a url string to be returned for the "url" from the "node:internal/modules/esm/resolve 'resolve'"
function but got type undefined.
at new NodeError (node:internal/errors:393:5)
at ESMLoader.resolve (node:internal/modules/esm/loader:872:13)
at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async file:///C:/Users/me/Documents/test.mjs:6:1 {
code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'
}
This is not really possible to fix. If you're trying to monkey-patch some code, I'd suggest modifying the specific objects you're working with rather than Object.prototype.
Activity
devsnek commentedon Oct 17, 2022
This is not really possible to fix. If you're trying to monkey-patch some code, I'd suggest modifying the specific objects you're working with rather than
Object.prototype.KhafraDev commentedon Oct 17, 2022
I'm (trying) to run a WPT that modifies Object.prototype and crashes the entire runner. If it's not possible to fix it can be closed :)
esm: protect ESM loader from prototype pollution
esm: protect ESM loader from prototype pollution
esm: protect ESM loader from prototype pollution
esm: protect ESM loader from prototype pollution