Skip to content
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

node >= 17: expiremental loader errs if http is imported into .mjs file #41320

Open
noahehall opened this issue Dec 25, 2021 · 4 comments
Open
Labels
loaders Issues and PRs related to ES module loaders

Comments

@noahehall
Copy link

noahehall commented Dec 25, 2021

Version

17.3.0

Platform

Linux spaceship 5.13.0-22-generic #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

esm loader, http

esm loader docs

What steps will reproduce the bug?

  • use an esm experimental loader to load somefile.mjs
  • inside of somefile.mjs add
import http from 'http';

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

always reproduces

What is the expected behavior?

the expiremental loader works, even when the docs tell us not to use it

What do you see instead?

 custom logic {
  format: 'module',
  isCjs: false,
  isFlow: false,
  urlOG: 'file:///home/poop/git/foss/nodeproto/packages/libraries/testproto/src/t.mjs'
}


 returning default file:///home/poop/git/foss/nodeproto/packages/libraries/testproto/src/t.mjs
TypeError [ERR_INVALID_URL_SCHEME]: The URL must be one of scheme file or data
    at new NodeError (node:internal/errors:371:5)
    at defaultGetSource (node:internal/modules/esm/get_source:38:11)
    at defaultLoad (node:internal/modules/esm/load:33:20)
    at load (file:///home/poop/git/foss/nodeproto/packages/libraries/testproto/node_modules/@nodeproto/configproto/src/node/loaders/flow.mjs:47:25)
    at async ESMLoader.load (node:internal/modules/esm/loader:359:20)
    at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:47)
 ELIFECYCLE  Command failed with exit code 1.

poop@spaceship:~/git/foss/nodeproto/packages/libraries/testproto

Additional information

more details

{
  '@nodeproto/testproto': '0.0.0',
  npm: '8.3.0',
  node: '17.3.0',
  v8: '9.6.180.15-node.12',
  uv: '1.42.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '102',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '3.0.1+quic',
  cldr: '40.0',
  icu: '70.1',
  tz: '2021a3',
  unicode: '14.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}

; "env" config from environment

_noahehall-registry = (protected) 
argv = "{\"remain\":[\"run\",\"repo:about\"],\"cooked\":[\"run\",\"repo:about\"],\"original\":[\"run\",\"repo:about\"]}" 
cache-dir = "/var/.nodeproto/pnpm" 
child-concurrency = "2" 
color = true 
enable-modules-dir = true 
fetch-retry-maxtimeout = 60000 
fetch-retry-mintimeout = 10000 
fetch-timeout = 60000 
global-bin-dir = "/var/.nodeproto/pnpm-global/bin" 
global-dir = "/var/.nodeproto/pnpm-global" 
hoist = true 
hoist-pattern = "['*']" 
link-workspace-packages = true 
lockfile = true 
loglevel = "info" 
modules-cache-max-age = "2880" 
modules-dir = "node_modules" 
node-gyp = "/home/poop/.node/corepack/pnpm/6.15.1/dist/node_modules/node-gyp/bin/node-gyp.js" 
package-import-method = "copy" 
prefer-frozen-lockfile = true 
prefer-offline = true 
prefer-workspace-packages = true 
recursive-install = true 
registry = "https://registry.npmjs.org/" 
save-exact = true 
save-prefix = "" 
shared-workspace-lockfile = true 
state-dir = "/var/.nodeproto/pnpm" 
store-dir = "/var/.nodeproto/.pnpm-store" 
symlink = true 
tag = "latest" 
use-beta-cli = true 
user-agent = "pnpm/6.15.1 npm/? node/v17.3.0 linux x64" 
virtual-store-dir = "node_modules/.pnpm" 

; node bin location = /opt/nodejs/node-v17.3.0-linux-x64/bin/node
; cwd = /home/poop/git/foss/nodeproto/packages/libraries/testproto
; HOME = /home/poop
; Run `npm config ls -l` to show all defaults.
npm timing command:c Completed in 9ms
npm timing npm Completed in 113ms
npm info ok 
NODE OPTIONS set to: --experimental-loader="./node_modules/@nodeproto/configproto/src/node/loaders/flow.mjs" --experimental-specifier-resolution=node --experimental-json-modules --experimental-top-level-await --experimental-vm-modules --experimental-import-meta-resolve node --enable-source-maps --heapsnapshot-near-heap-limit=3 --use-largepages=on --pending-deprecation --trace-sigint --trace-warnings --trace-exit --report-uncaught-exception --report-on-fatalerror --abort-on-uncaught-exception

@noahehall noahehall changed the title node >= 17: epiremental loader errs if http is imported into .mjs file node >= 17: expiremental loader errs if http is imported into .mjs file Dec 25, 2021
@noahehall
Copy link
Author

noahehall commented Dec 25, 2021

relevant section that throws err in expiremental loader

if (!isFlow) {
    if (isCjs) return { format, source: rawSource };
    else {
      console.info('\n\n returning default', urlOG); //  <-- this is the log shown in description
      return defaultLoad(urlOG, { format }); // <-- this is whats throwing the err
    }
  }

noahehall added a commit to noahehall/nodeproto that referenced this issue Dec 25, 2021
@Mesteery Mesteery added loaders Issues and PRs related to ES module loaders v17.x labels Dec 25, 2021
@aduh95
Copy link
Contributor

aduh95 commented Dec 25, 2021

/cc @nodejs/loaders

@bmeck
Copy link
Member

bmeck commented Dec 25, 2021 via email

@noahehall
Copy link
Author

@bmeck loader source text

@targos targos removed the v17.x label Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
loaders Issues and PRs related to ES module loaders
Projects
None yet
Development

No branches or pull requests

5 participants