Skip to content

[flow] Share the crawl file filter between full and subdirectory crawls - #9532

Closed
robhogan wants to merge 1 commit into
meta:mainfrom
robhogan:crawl-file-filter
Closed

robhogan wants to merge 1 commit into
meta:mainfrom
robhogan:crawl-file-filter

Conversation

@robhogan

@robhogan robhogan commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

make_next_files filters each file it finds with no_subdir_path_filter, or with subdir_path_filter when the crawl is limited to a subdirectory. The latter repeats path_is_in_crawl_scope inline, plus a starts_with(subdir) check.

This moves the subdirectory check into path_is_in_crawl_scope and replaces both filters with one crawl_path_filter. It's the base of the stack fixing #9529, where the crawl never finishes on pnpm workspaces. The fix stops following a symlink when the crawl reads its target anyway, and decides that with this same scope check rather than a copy of it:

robhogan@94f7d3d

Test plan:
The conditions and their order are unchanged. tests/ls covers full, subdirectory, [include] and --all crawls, and the full flow dev-tools runtests suite passes (macOS).

`make_next_files` filters each file it finds with `no_subdir_path_filter`, or with `subdir_path_filter` when the crawl is limited to a subdirectory. The latter repeats `path_is_in_crawl_scope` inline, plus a `starts_with(subdir)` check.

This moves the subdirectory check into `path_is_in_crawl_scope` and replaces both filters with one `crawl_path_filter`, so there's a single definition of which files the crawl reports. The fix for meta#9529 needs to ask the crawl's scope the same question about a symlink's target.

Test plan:
The conditions and their order are unchanged. `tests/ls` covers full, subdirectory, `[include]` and `--all` crawls, and the full `flow dev-tools runtests` suite passes (macOS).
@meta-codesync

meta-codesync Bot commented Nov 17, 2026

Copy link
Copy Markdown

This pull request has been imported. If you are a Meta employee, you can view this in D132631202. (Because this pull request was imported automatically, there will not be any future comments.)

@meta-codesync meta-codesync Bot closed this in b4aaa29 Nov 18, 2026
@meta-codesync

meta-codesync Bot commented Nov 18, 2026

Copy link
Copy Markdown

This pull request has been merged in b4aaa29.

@meta-codesync meta-codesync Bot added the Merged label Nov 18, 2026
meta-codesync Bot pushed a commit that referenced this pull request Nov 19, 2026
Summary:
Fixes #9529

Last part of the stack #9532, #9533, #9534 (split from #9530).

#9534 stops the file crawl following a symlink to a directory it reads anyway, but it still follows any other symlink, eg out of the root or out of the directory passed to `flow ls`, and goes round a cycle of them until the OS refuses to resolve the path. With a few packages linked to each other, eg `flow ls packages/a` in a pnpm workspace, that never ends in practice.

This stops following a symlink to a directory the crawl passed through to reach it. Every walk now ends, though a dense web of links out of the crawl is still walked once per path through it, which grows quickly with the number of links.

Pull Request resolved: #9535

Test Plan:
`symlinks_out_of_root` now also has a cycle out of the root, whose files `main` lists once per lap. The full `flow dev-tools runtests` suite passes (macOS).

On react/metro installed with pnpm (react/metro#2110), `flow ls packages/metro-config` hangs on `main`. With this, `flow ls` of each workspace package finishes in under a second, and `flow full-check` gives the same result in the same time.

Reviewed By: SamChou19815

Differential Revision: D133227488

fbshipit-source-id: 889fee75094aed805ff360dbd21939cbe8cf465b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant