Skip to content

custom loader fails to resolve nested http(s) import #42721

Closed
@basmasking

Description

@basmasking

Version

v17.9.0

Platform

Darwin MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

Use a custom loader based on the http loader example
Start node with the --experimental-loader flag.
Try to load any external esm module file via https using the following function

import('https://my-domain.com/my-module.js'); 

How often does it reproduce? Is there a required condition?

Always from version v17.7.0 and onwards

What is the expected behavior?

To load and import the external module

What do you see instead?

The data is loaded in the custom loader as a string and gets resolved as the loader example. Then the following error is thrown.

Error [ERR_INTERNAL_ASSERTION]: Base url for module undefined not loaded.
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
    at new NodeError (node:internal/errors:372:5)
    at ESMLoader.getBaseURL (node:internal/modules/esm/loader:290:15)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:37)
    at link (node:internal/modules/esm/module_job:78:36)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_INTERNAL_ASSERTION'
}

Additional information

No response

Metadata

Metadata

Labels

confirmed-bugIssues with confirmed bugs.loadersIssues and PRs related to ES module loaders

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions