-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
require() no longer follows symlinks after calling statSync() on a FIFO or socket file #51142
Comments
Some additional information: if you call const fs = require("fs");
fs.statSync("fifo");
fs.statSync("/home");
require("top-level-dependency");
console.log("Success!"); Our working theory is that there is some shared or global state that is corrupted when |
@nodejs/loaders @nodejs/fs I think first we should narrow down which release of Node (or ideally which commit) introduced the bug. There have been a handful of changes to CommonJS in the last year and some refactors to fs, so it could be either. |
I'm getting killed by this bug on NodeJS 20.x I think. I've stepped through the module require system into the implementation of Lines 2711 to 2718 in 19b6fc9
Specifically it is going into the I'm not very familiar with the nodejs internals, but I'm inferring from some reading that I think this usually doesn't blow up because other parts of the module loading system tend to have run stat on various files & directories, just before this, but sometimes things go weird. Attaching strace to my process, it seems like the socket stat triggering this and leading to my particular misery today is from VSCode vue.js tooling, but that just happens to be one case. The code reading the |
+ |
Version
v20.10.0
Platform
Linux debian 6.1.0-13-arm64 #1 SMP Debian 6.1.55-1 (2023-09-29) aarch64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
This issue was discovered when using
pnpm
and dependencies downloaded from NPM, but it can be reproduced with some simple shell commands instead.node_modules
structure that emulatespnpm
's virtual store technique where dependencies are symlinked from the root of thenode_modules
into a virtual store directory called.pnpm
:mkfifo
utility:Note that these files differ only by the removal of the
statSync
call.How often does it reproduce? Is there a required condition?
Every time. The only requirement I have found is that the argument to
statSync()
be either a socket or FIFO file (i.e. a directory or regular file would not cause the issue).What is the expected behavior? Why is that the expected behavior?
$ node success.js Success!
This behaviour is expected because Node is supposed to follow symlinks when resolving modules and use the real path when resolving the transitive dependencies of those modules.
What do you see instead?
Additional information
I have debugging output with
NODE_DEBUG
that shows that the symlink from the root of thenode_modules
is not followed into the.pnpm
subdirectory as it should in the case that thestatSync()
call is made.I have also got
strace
output that I can share, if that would be of assistance.My colleagues have been able to reproduce this issue, both on the same Debian OS as me, and on MacOS (i.e. Darwin).
The text was updated successfully, but these errors were encountered: