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

--use-loader fails with NodeJS 20.0.0 #39

Open
aheissenberger opened this issue Apr 28, 2023 · 6 comments
Open

--use-loader fails with NodeJS 20.0.0 #39

aheissenberger opened this issue Apr 28, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@aheissenberger
Copy link

The command will finish after some time without any output:

node ➜ /workspaces/vite-plugin-ssr $ node --version
v20.0.0
node ➜ /workspaces/vite-plugin-ssr $ ./node_modules/.bin/vavite serve --use-loader
node ➜ /workspaces/vite-plugin-ssr $ 

a look at the processes (ps xa) shows these processes still running in the background:

140 ?        Sl     0:00 /home/node/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /tmp/vscode-remote-containers-server-a3221ea0-253e-466a-9700-2aae643dd
  152 ?        Ss     0:00 sh /home/node/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/bin/code-server --log debug --force-disable-user-env --server-data-dir /
  167 ?        Sl     0:02 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436
  217 ?        Rl     0:02 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436
  239 ?        Ssl    0:00 /home/node/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node -e  ????const net = require('net'); ????const fs = require('fs'); ????
  284 ?        Ssl    0:00 /home/node/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node -e  ????const net = require('net'); ????const fs = require('fs'); ????
  296 ?        Sl     0:00 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436
  310 ?        Rl     0:05 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436
  326 pts/0    Ss+    0:00 /bin/bash --init-file /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/contrib/terminal/browser/med
  374 ?        Sl     0:01 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node --max-old-space-size=3072 /vscode/vscode-server/bin/linux-arm6
  376 ?        Sl     0:03 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node --max-old-space-size=3072 /vscode/vscode-server/bin/linux-arm6
  392 ?        Sl     0:00 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436
  413 ?        Sl     0:00 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /home/node/.vscode-server/extensions/dbaeumer.vscode-eslint-2.
  622 ?        Sl     0:00 /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/node /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436
  814 pts/0    Sl     0:10 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
  845 pts/0    Sl     0:10 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
  891 pts/0    Sl     0:09 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
  939 pts/0    Sl     0:09 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
  985 pts/0    Sl     0:08 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1050 pts/0    Sl     0:08 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1117 pts/0    Sl     0:08 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1175 pts/0    Sl     0:07 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1240 pts/0    Sl     0:07 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1319 pts/0    Sl     0:07 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1388 pts/0    Sl     0:06 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1477 pts/0    Sl     0:06 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1565 pts/0    Sl     0:06 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1673 pts/0    Sl     0:05 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1766 pts/0    Sl     0:05 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1854 pts/0    Sl     0:04 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 1949 pts/1    Ss     0:00 /bin/bash --init-file /vscode/vscode-server/bin/linux-arm64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/contrib/terminal/browser/med
 2003 pts/0    Sl     0:03 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 2208 pts/0    Sl     0:02 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader
 2390 pts/0    Rl     0:01 /usr/local/bin/node /workspaces/vite-plugin-ssr/node_modules/vavite/cli.js serve --use-loader

This problem does not exist if I downgrade to node version 18 - replace 20:
.devcontainer/devcontainer.json switch number in image tag ..javascript-node:0-20-bullseye

Here is my repo including a VSCode DevContainer to simulate the problem:
https://github.com/aheissenberger/vavite-node-loader-node20-fail

I have exactly the same problem with the nodejs 20.0.0 version on MacOS installed with brew.

@cyco130 cyco130 added the bug Something isn't working label Apr 28, 2023
@cyco130
Copy link
Owner

cyco130 commented May 2, 2023

Thank you for reporting!

This is a bug in Node.js itself and, per the comments on the issue, will be fixed in 20.1.0 (or 20.0.1 if one is ever released). Until then I suggest you downgrade to 18 or 19.

@cyco130 cyco130 closed this as completed May 2, 2023
@cyco130
Copy link
Owner

cyco130 commented May 4, 2023

Reopening because 20.1.0 was released today but it hasn't solved the problem. I'm still pretty sure it's a Node issue but we need to investigate just in case.

@cyco130 cyco130 reopened this May 4, 2023
@aheissenberger
Copy link
Author

aheissenberger commented May 5, 2023

@cyco130 My test with node 20.1.0 show no change in the behavior - thanks for finding the node issue!
Do you have a simpler setup to reproduce the problem? I would like to post a framework independent code sample to the node repo to show them the that the problem is not fixed but I know too less about loaders to prepare such an example.

@aheissenberger
Copy link
Author

@cyco130 please have a look at this problem - I tested with node version 20.2.0 and the problem still exists.

@cyco130
Copy link
Owner

cyco130 commented May 29, 2023

I now know the root cause: Node 20 runs ESM loaders in a separate thread but Vavite's loader relies on a global variable. This will require a substantial rework of the system: We'll have to proxy everything through a message channel. As such, it will require quite a bit of time :(

If you're using --use-loader for sourcemap support, you might not need it anymore. If you're using it for some other reason, I suggest you stick with Node 18 or 19 for the time being as the fix might take some time to complete.

@aheissenberger
Copy link
Author

I now know the root cause: Node 20 runs ESM loaders in a separate thread but Vavite's loader relies on a global variable. This will require a substantial rework of the system: We'll have to proxy everything through a message channel. As such, it will require quite a bit of time :(

🙁 this sounds really like a lot of work - maybe you should not support nodejs v20.x and exit the loader with a message pointing to this issue

If you're using --use-loader for sourcemap support, you might not need it anymore. If you're using it for some other reason, I suggest you stick with Node 18 or 19 for the time being as the fix might take some time to complete.

Debugging the backend with sourcemaps is my only use case and I can confirm this works now with nodejs v20.2.0 and even with version v20.0.0 like a charm - thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants