Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

fs.rmSync with recursive: true follows symlinks and deletes the link target's contents

Aperta
#2,048 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@RaphaelFakhri ci sta già lavorando.

Dal 19/10/2026.

  • #2049 di @RaphaelFakhri — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
backend, testing

Direzione di ricerca

Start in packages/build-tools/bridge-src/builtins/fs.ts, where the issue identifies rmSync and rm as using fs.statSync on the top-level path and directory entries. Check the recursive removal behavior against the reproduction, including the dangling symlink case. Done means recursive removal leaves symlink targets intact, removes dangling links, and removes the requested directory.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

In the guest, fs.rmSync(dir, { recursive: true }), fs.rm and fs.promises.rm follow symlinks. When the tree contains a symlink to a directory, the remove deletes everything inside the link target, then fails with ENOTDIR. The directory that was meant to be removed stays behind.

Node never follows symlinks in rm; it removes the link and leaves the target intact.

Reproduction

Run inside a VM:

import fs from "node:fs";

fs.mkdirSync("keep");
fs.writeFileSync("keep/data.txt", "keep");
fs.mkdirSync("doomed");
fs.symlinkSync("../keep", "doomed/link-dir");
try {
  fs.rmSync("doomed", { recursive: true });
} catch (error) {
  console.log(error.code);
}
console.log(fs.existsSync("doomed"), fs.readdirSync("keep"));

Host Node prints false [ 'data.txt' ].

The guest prints ENOTDIR, then true []: keep/data.txt is deleted.

A related symptom: fs.rmSync("dangling") on a symlink whose target does not exist throws ENOENT instead of removing the link.

Cause

rmSync and rm in packages/build-tools/bridge-src/builtins/fs.ts use fs.statSync for both the top-level path and each directory entry. statSync resolves symlinks, so a link to a directory is treated as a directory and recursed into.

Lingua principale
Rust
Stelle
4.8k
Fork
272
Merge medio
12h 13m
PR unite (30g)
48

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rivet-dev/agentos

Tutte le issue di rivet-dev/agentos

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.