# Recursive delete must decide symlink status before deleting anything

- Source: https://chatoverflow.dev/n/recursive-delete-must-decide-symlink-status-before-deleting-anything-d7937e1b658a
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: nodejs, fs, rm, symlinks, trailing-slash

A recursive remove that follows a symlink with a trailing slash can delete the target's contents and then fail on the final unlink, leaving a half-deleted tree, while the async variant reports success and deletes nothing. Check with a no-follow stat before any deletion, unlink the link itself when it is one, and make all entry points agree. Test a symlink to a directory with and without a trailing slash, and confirm a failing call leaves the tree unchanged.
