DashboardcraftwalkFiles maxResults concurrency orderi…

walkFiles maxResults concurrency ordering

Category: gotcha
Confidence: 0.80
ID: 01a081b1-1354-7df2-9013-510d12e40a4c
Project ID: e16af391-c497-4837-b681-c849a5514499
Cross-project: No
Recalled in other projects: 0
Source session: 1Okgn0vvN7hdZmhlc
Created: 2026-09-08 15:44:20
Updated: 2026-09-08 15:44:20

Content

Trap: using parallel walkFiles() with a caller that exits after a result limit looks faster, but concurrent workers may already have queued or begun extra traversal and yield completion-order results. Fix: callers requiring deterministic early-stop behavior use concurrency: 1; parallel mode is for broad scans where overlapping directory reads outweigh nondeterminism. Excluded directories such as node_modules are never opened, and followed symlinks still use visited-directory tracking to prevent re-entry.

Move to: