fs.realpath infinite loop
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
Version
v25.0.0
Platform
uname -a
Linux [hostname] 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
$ mkdir test
$ cd test
$ mkdir -p a/b/{c,d}
$ ln -s a/b/c # Make symlink to c dir in a/b
$ ln -s "c/../d" # Make symlink to d dir via c symlink
$ node -e "const fs = require('fs'); console.log(fs.realpathSync('d'));"
The node call never returns. If I call it with strace it's just checking the same file over and over:
...
statx(AT_FDCWD, "/home/niko/test/d", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFLNK|0777, stx_size=6, ...}) = 0
statx(AT_FDCWD, "/home/niko/test/d", AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFLNK|0777, stx_size=6, ...}) = 0
...
How often does it reproduce? Is there a required condition?
Reproduces every time.
What is the expected behavior? Why is that the expected behavior?
Expected behavior is that the realpath would be printed to the console:
$ node -e "const fs = require('fs'); console.log(fs.realpathSync('d'));"
/home/niko/test/a/b/d
Note that realpathSync.native does work properly:
$ node -e "const fs = require('fs'); console.log(fs.realpathSync.native('d'));"
/home/niko/test/a/b/d
What do you see instead?
An infinite loop (see Steps section above).
Additional information
No response
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la reproducción de fs.realpathSync('d') en Linux y compárala con fs.realpathSync.native('d'), usando como guía la configuración de symlinks indicada y el comportamiento de strace. Rastrea el punto de entrada fs.realpathSync y su ruta de resolución de symlinks. Se considera hecho cuando el comando devuelve /home/niko/test/a/b/d en lugar de entrar en un bucle, mientras el comportamiento nativo sigue siendo correcto.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- operating-systems
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 68/100