Skip to content

fix: resolve symlinked in packageDirectory in local tracking-W-24254666 - #897

Merged
WillieRuemmele merged 4 commits into
mainfrom
sl/W-24254666
Oct 28, 2026
Merged

WillieRuemmele merged 4 commits into
mainfrom
sl/W-24254666

Conversation

@soridalac

Copy link
Copy Markdown
Member

Summary

  • Symlinked packageDirectory paths silently contribute zero components to deploys — no error, no warning
  • isomorphic-git 1.38.10+ classifies symlinked directories as blob instead of tree via lstat, so the walker never descends into them
  • Override lstat in the fs object passed to isomorphic-git to follow symlinks to directories, so the shadow repo walker enumerates files inside symlinked packageDirs
  • Read-only change — the shadow repo only reads file content for change detection, never writes to the user's project

Test plan

  • Existing unit tests pass
  • New test: symlinked packageDirectory root — files detected
  • New test: symlink in middle of packageDirectory path — files detected

@W-24254666@
cli issue: forcedotcom/cli#3653

@WillieRuemmele

WillieRuemmele commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

I reproduced two local-source-tracking regressions against the real Dreamhouse LWC project (trailheadapps/dreamhouse-lwc), comparing main at 15c6fa6 with this PR at dddeab2.

The PR adapter follows every directory symlink encountered by the status walker, not only symlinks needed to reach a configured packageDirectory.

  1. Directory-link cycle
cd dreamhouse-lwc
ln -s . force-app/source-tracking-cycle
# Run local source tracking.
rm force-app/source-tracking-cycle
  • Base: PASS: 163 tracked files
  • This PR: ELOOP: too many symbolic links encountered, stat .../force-app/source-tracking-cycle/source-tracking-cycle/...

The walker recursively follows the link until Node aborts the scan, preventing source tracking for the project.

  1. Dangling symlink
cd dreamhouse-lwc
ln -s source-tracking-missing-target force-app/source-tracking-dangling
# Run local source tracking.
rm force-app/source-tracking-dangling
  • Base: PASS: 163 tracked files
  • This PR: ENOENT: no such file or directory, lstat 'force-app/source-tracking-dangling'

lstat succeeds for the existing link, but the adapter then calls stat, which rejects because the target is missing. That aborts the complete scan despite the valid metadata alongside it.

For a repeatable setup/cleanup, this is the complete local script I used (it is not part of this PR):

import { rm, symlink } from 'node:fs/promises';
import path from 'node:path';

const packageDir = path.join(process.cwd(), 'force-app');
const scenario = process.argv[2];
const cycle = path.join(packageDir, 'source-tracking-cycle');
const dangling = path.join(packageDir, 'source-tracking-dangling');

await Promise.all([rm(cycle, { force: true }), rm(dangling, { force: true })]);
if (scenario === 'cycle') await symlink('.', cycle, 'dir');
if (scenario === 'dangling') await symlink('source-tracking-missing-target', dangling, 'file');

Run it as node reproduce.mjs cycle or node reproduce.mjs dangling; run node reproduce.mjs to remove the temporary links.

Could we constrain directory-link following to the configured package-directory path segments, rather than overriding lstat globally for all walker descendants? At minimum, preserve the original lstat result when target resolution fails and add regression coverage for both a nested cycle and dangling link.

@WillieRuemmele

Copy link
Copy Markdown
Member

QA overview

Validated the updated implementation at e0affb9 against the real Dreamhouse LWC project and the focused unit suite.

Scenario Result
Symlinked packageDirectory root Passes
Symlinked ancestor in the configured package-directory path Passes
Nested directory-link cycle: force-app/source-tracking-cycle -> . Passes; source tracking reports 163 files without ELOOP
Nested dangling link: force-app/source-tracking-dangling -> missing-target Passes; source tracking reports 163 files without ENOENT

The revised path-scoped adapter preserves the intended symlinked-package-directory behavior while leaving symlinks inside a package directory untouched. That resolves both regressions from the initial global lstat override.

Additional verification:

  • yarn compile passed at the updated head.
  • Focused localShadowRepo symlink tests: 4 passing.
  • PR CI is passing across Linux/Windows unit and tracking NUT jobs; the Ubuntu test:nuts:deb job is still pending at time of review.
  • Temporary Dreamhouse symlink fixtures were removed after verification.

Non-blocking follow-up: the stat fallback catches all errors. It would be slightly safer to preserve the original lstat result only for expected resolution failures (ENOENT, ENOTDIR, ELOOP) and rethrow permission/I/O failures such as EACCES or EIO. This does not affect the validated scenarios or the core approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants