Skip to content

Commit 1e5afb7

Browse files
ChALkeRtargos
authored andcommitted
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
This restores a broken and erroneously removed error, which was accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice the "INTST" vs "INST") in 921fb84 (PR #16874) and then had documentation and implementation removed under the old name in 6e1c25c (PR #18857), as it appeared unused. This error code never worked or was documented under the mistyped name ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix. Refs: #21440 Refs: #21470 Refs: #16874 Refs: #18857 PR-URL: #21493 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 95fa3c6 commit 1e5afb7

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

doc/api/errors.md

+8
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,14 @@ strict compliance with the API specification (which in some cases may accept
13401340
`func(undefined)` and `func()` are treated identically, and the
13411341
[`ERR_INVALID_ARG_TYPE`][] error code may be used instead.
13421342

1343+
<a id="ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK"></a>
1344+
### ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
1345+
1346+
> Stability: 1 - Experimental
1347+
1348+
An [ES6 module][] loader hook specified `format: 'dynamic'` but did not provide
1349+
a `dynamicInstantiate` hook.
1350+
13431351
<a id="ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST"></a>
13441352
### ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST
13451353

lib/internal/errors.js

+3
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,9 @@ E('ERR_MISSING_ARGS',
747747
}
748748
return `${msg} must be specified`;
749749
}, TypeError);
750+
E('ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
751+
'The ES Module loader may not return a format of \'dynamic\' when no ' +
752+
'dynamicInstantiate function was provided', Error);
750753
E('ERR_MISSING_MODULE', 'Cannot find module %s', Error);
751754
E('ERR_MODULE_RESOLUTION_LEGACY',
752755
'%s not found by import in %s.' +

lib/internal/modules/esm/loader.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {
55
ERR_INVALID_RETURN_PROPERTY,
66
ERR_INVALID_RETURN_PROPERTY_VALUE,
77
ERR_INVALID_RETURN_VALUE,
8-
ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK,
8+
ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK,
99
ERR_UNKNOWN_MODULE_FORMAT
1010
} = require('internal/errors').codes;
1111
const { URL } = require('url');
@@ -118,7 +118,7 @@ class Loader {
118118
let loaderInstance;
119119
if (format === 'dynamic') {
120120
if (typeof this._dynamicInstantiate !== 'function')
121-
throw new ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK();
121+
throw new ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK();
122122

123123
loaderInstance = async (url) => {
124124
debug(`Translating dynamic ${url}`);

0 commit comments

Comments
 (0)