Skip to content

fix(ignoreWalker): remove default rule cache to prevent stale rules in long-running processes#89

Merged
gregpriday merged 3 commits into
developfrom
bugfix/issue-84-stale-ignore-rule-cache-long
Feb 26, 2026
Merged

fix(ignoreWalker): remove default rule cache to prevent stale rules in long-running processes#89
gregpriday merged 3 commits into
developfrom
bugfix/issue-84-stale-ignore-rule-cache-long

Conversation

@gregpriday
Copy link
Copy Markdown
Owner

Summary

Removes the always-on module-level ruleCache from ignoreWalker.js that caused stale ignore rules in long-running host processes (Electron/library use). In a short-lived CLI process the cache is discarded on exit, but in a long-running process it persists across copy() calls — causing incorrect file lists when .gitignore or .copytreeignore changes on disk or the user switches branches.

Closes #84

Changes Made

  • Remove default cache: readRules() no longer caches by default; cache is opt-in via { cache: true } on walkWithIgnore, getAllFiles, and testPath
  • Add clearRuleCache() export: callers who enable caching can call this between operations to invalidate stale entries
  • Fix transient error caching: only ENOENT (file not found) results are cached; transient errors (EMFILE, EACCES) are not cached so they resolve on the next call
  • JSDoc updates: added @param for cache option on all three public functions; corrected testPath return type (rule/layer are nullable)
  • 6 new unit tests: no-cache freshness, opt-in staleness, clearRuleCache round-trip, newly created ignore file (both no-cache and cached), and testPath cache parity

- Add missing "peer": true annotations to @babel/eslint-parser,
  @types/node, acorn, browserslist, eslint-visitor-keys, and react
  entries after post-merge npm install
…n long-running processes

- Remove default-on caching from readRules(); cache is now opt-in via
  { cache: true } option on walkWithIgnore, getAllFiles, and testPath
- Add clearRuleCache() export so callers who enable caching can
  invalidate between operations
- Only cache ENOENT (file-not-found) results; transient errors
  (EMFILE, EACCES) are no longer cached to prevent sticky empty rules
- Add JSDoc for cache option on all three public functions and correct
  testPath return type (rule/layer are nullable, not always strings)
- Add 6 unit tests covering: no-cache freshness, opt-in staleness,
  clearRuleCache round-trip, newly created file (no-cache and cached),
  and testPath cache parity
@gregpriday gregpriday merged commit f429448 into develop Feb 26, 2026
2 of 7 checks passed
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.

Stale ignore-rule cache in long-running processes (Electron/library use)

1 participant