Handle broken symlinks gracefully during file tracing
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Inizia con src/fs.ts e src/node-file-trace.ts, seguendo nodeFileTrace fino a realpath e ai percorsi delle voci di directory che chiamano stat. Confronta questi percorsi con _internalReadlink e _internalStat, quindi riproduci lo scenario del symlink non valido su Node.js. Il lavoro è completato quando il tracing continua dopo ENOENT e la destinazione non valida è assente da fileList.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
When @vercel/nft traces dependencies in an environment containing broken symlinks
(symlinks whose target does not exist), the tracing process throws an unhandled
ENOENT error and aborts entirely.
Steps to Reproduce
- Create a broken symlink in the system (e.g.,
/etc/alternatives/which.sl1.gz
pointing to a non-existent target) - Run
nodeFileTrace()on an entry file whose dependency chain resolves through
that directory (e.g., via a binary that references/usr/bin/which→
/etc/alternatives/which) - The trace fails with: Error: ENOENT: no such file or directory, stat '/etc/alternatives/which.sl1.gz'
Expected Behavior
Broken symlinks should be skipped gracefully (similar to how _internalReadlink
already handles ENOENT by returning null). The trace should continue and
simply not include the broken symlink target in the output fileList.
Actual Behavior
The entire trace aborts with an unhandled ENOENT error, preventing any output
from being generated.
Environment
@vercel/nftversion: 0.29.2- Node.js: 20.x
- OS: Linux (CI container based on CentOS/Alpine with stale symlinks in
/etc/alternatives)
Analysis
In src/fs.ts, _internalStat correctly returns null for ENOENT. However,
the realpath() method in src/node-file-trace.ts recursively resolves paths
by calling readlink → resolve → realpath again. During this recursion,
when the resolved path traverses a directory that contains broken symlinks,
subsequent operations on adjacent files (like glob-based asset emission or
shared library detection) may attempt to stat those broken symlinks through
a code path that does not handle the null/ENOENT return gracefully.
Suggested Fix
Ensure that any code path that calls stat() or processes directory entries
during tracing handles broken symlinks (stat returning null) by skipping
the entry rather than propagating the error.
- Lingua principale
- JavaScript
- Stelle
- 1.7k
- Fork
- 191
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel/nft
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 74/100
-
`require()` inside an ES module is resolved with the `import` condition, tracing the wrong file of a dual packageForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
`path.resolve()` on unknown segments emits a cwd-wide globForse già presa @florian-lefebvre l’ha presa 11 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
-
`createRequire` is not traced when the `node:module` namespace import is not named `module`Forse già presa @falklinus l’ha presa 11 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 73/100
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
githubnext/gh-aw-workshop#5522 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Dayset/ps2-elite-kd#119 ·
-
Add: Hindi Hits LogoApertacheck:passed logos:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
area:models enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
scout
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
oskarrough/agent-ide#43 ·