Skip to content

Commit 75f2e05

Browse files
committed
fixup: assert baseURL is a string for network modules
1 parent a8f2e7f commit 75f2e05

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/internal/modules/esm/loader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323
const { MessageChannel } = require('internal/worker/io');
2424

2525
const {
26+
ERR_INTERNAL_ASSERTION,
2627
ERR_INVALID_ARG_TYPE,
2728
ERR_INVALID_ARG_VALUE,
2829
ERR_INVALID_RETURN_PROPERTY_VALUE,
@@ -260,6 +261,10 @@ class ESMLoader {
260261
// fetchModule's cache, in which case, fetchModule returns
261262
// immediately and synchronously
262263
url = fetchModule(new URL(url), { parentURL: url }).resolvedHREF;
264+
// This should only occur if the module hasn't been fetched yet
265+
if (typeof url !== 'string') {
266+
throw new ERR_INTERNAL_ASSERTION(`Base url for module ${url} not loaded.`);
267+
}
263268
}
264269
return url;
265270
}

0 commit comments

Comments
 (0)