Skip to content

endless recursion when dir has symlink which points to its parent dir #12080

@zhsj

Description

@zhsj

Environments:

  • Prettier Version: 2.5.1
  • Running Prettier via: CLI
  • Runtime: Node.js v16.13.0
  • Operating System: Linux
  • Prettier plugins (if any): none

Steps to reproduce:

First create the test dirs.

mkdir -p ./x1 ./y1
ln -sf .. ./x1/x2
ln -sf .. ./y1/y2

It should look like:

$ tree
.
├── x1
│   └── x2 -> ..
└── y1
    └── y2 -> ..

4 directories, 0 files

Then run prettier cli

prettier -c .

Try adding these dirs to .prettierignore and run again:

$ cat .prettierignore 
x1
y1

Expected behavior:

No error.

Or these problematic dirs can be excluded by .prettierignore file.

Actual behavior:

The command will run for a long time, and then produce an error.

[error] Unable to expand directory: .
[error] ELOOP: too many symbolic links encountered, scandir '/tmp/t/prettier-bug/x1/x2/x1/x2/x1/x2/x1/x2/x1/x2/y1/y2/y1/y2/x1/x2/y1/y2/x1/x2/y1/y2/y1/y2/x1/x2/x1/x2/y1/y2/y1/y2/x1/x2/y1/y2/x1/x2/x1/x2/x1/x2'

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliIssues with Prettier's Command Line Interfacelocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions