Fix ELOOP error when comparing folders with circular symlinks #228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users encounter
ELOOP: too many symbolic links encounterederrors when comparing folders that contain circular symbolic links. The error occurs in thedir-comparelibrary when it tries to stat a symlink that forms an infinite loop, causing the comparison to fail completely.Example error:
Root Cause
The issue stems from the
dir-comparelibrary (v4.2.0) which only handles broken symlinks (ENOENTerrors) but doesn't catchELOOPerrors that occur when encountering circular symbolic links. The error happens in thegetStatIgnoreBrokenLinkfunction before any symlink filtering can take place.Solution
This PR adds two improvements to handle this scenario:
1. New
skipSymlinksConfiguration OptionAdded a new user-configurable setting
compareFolders.skipSymlinks(default:false) that allows users to skip symbolic links during comparison. This option is passed to thedir-comparelibrary and helps avoid various symlink-related issues during folder comparison.Usage:
{ "compareFolders.skipSymlinks": true }2. Enhanced Error Handling
The comparison logic now specifically catches
ELOOPerrors and provides a helpful, actionable error message that includes the path to the problematic symlink:This gives users clear guidance on what went wrong and where to find the issue.
Limitations
Due to the timing of when
ELOOPerrors occur in thedir-comparelibrary (during the initial stat call), theskipSymlinksoption cannot prevent these specific errors. However, it remains useful for filtering out symlinks in general and avoiding other symlink-related issues. Users encounteringELOOPerrors will need to fix or remove the circular symlinks manually.Changes
compareFolders.skipSymlinksconfiguration option topackage.jsonIConfigurationsinterface insrc/services/configuration.tssrc/services/comparer.tsto catch and reportELOOPerrors with helpful messagesTesting
Fixes #[issue_number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
update.code.visualstudio.com/usr/local/bin/node ./out/test/runTest.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #226
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.