Skip to content

perf(browsers): reduce synchronous existsSync calls in file discovery#495

Merged
mherod merged 2 commits intomainfrom
perf/issue-489-reduce-existssync-calls
Mar 15, 2026
Merged

perf(browsers): reduce synchronous existsSync calls in file discovery#495
mherod merged 2 commits intomainfrom
perf/issue-489-reduce-existssync-calls

Conversation

@mherod
Copy link
Copy Markdown
Owner

@mherod mherod commented Mar 15, 2026

Summary

  • Replace iterative existsSync calls with single fg.sync() glob patterns in Chromium and Firefox profile discovery
  • Cache browser installation checks at module level (installCache Map) since installations don't change during process lifetime
  • Update EnhancedCookieQueryService tests to mock fast-glob instead of readdirSync

Reduces 20-40 synchronous stat syscalls per query lifecycle to ~3-5 glob calls.

Closes #489

Test plan

  • pnpm type-check passes
  • pnpm lint passes (Biome, 225 files)
  • All 588 tests pass
  • Pre-push validation passes (full validate pipeline)

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: fast-glob refactor for profile discovery. Clean performance improvement replacing up to 12 sequential existsSync calls with single glob patterns, plus module-level installation caching. Key positives: behavior improvement (old code silently capped Chromium profiles at 10, Profile * glob now finds all profiles correctly); guard checks ensure fg.sync is never called with non-existent cwd; installCache invariant is well-documented; tests cleanly mock fast-glob; fast-glob already in package.json. Minor non-blocking note: the Firefox path in EnhancedCookieQueryService lost a debug log on readdirSync failure, but propagating unexpected errors is arguably better than silent swallowing. LGTM.

- Replace iterative existsSync calls with single fg.sync() glob
  patterns in profile discovery (BrowserAvailability.ts and
  EnhancedCookieQueryService.ts)
- Cache browser installation checks at module level since
  installations don't change during process lifetime
- Update tests to mock fast-glob instead of readdirSync

Fixes #489
@mherod mherod force-pushed the perf/issue-489-reduce-existssync-calls branch from 4cf6bba to 8303f8b Compare March 15, 2026 20:53
@mherod mherod merged commit e3f1b4c into main Mar 15, 2026
15 checks passed
@mherod mherod deleted the perf/issue-489-reduce-existssync-calls branch March 15, 2026 21:30
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.

perf(browsers): reduce synchronous existsSync calls in file discovery hot paths

1 participant