You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flow hangs crawling pnpm workspaces (symlink cycles in node_modules) #9529
When workspace packages are linked into each other's node_modules, as pnpm does with linkWorkspacePackages: true, flow ls and flow check never finish.
We ran into this in the wild while adding pnpm tests to Metro. Under pnpm, flow check got past ~1M parsed files before I killed it - under Yarn's hoisted layout the same project has ~23k files and checks in a few seconds. The draft PR adding pnpm support has to work around it in .flowconfig:
mkdir -p repro/packages/{a,b,c,d,e,f} &&cd repro
printf'[options]\nall=true\n'> .flowconfig
forpin a b c d e f;doecho'// @flow'> packages/$p/index.js
mkdir packages/$p/node_modules
forqin a b c d e f;do [ $p!=$q ] && ln -s ../../$q packages/$p/node_modules/$q;donedone
flow ls # doesn't return
With only two packages linked to each other, flow ls does return, but lists each file 33 times.
The crawl follows symlinks with jwalk, whose loop check compares the raw link target (../../b) with the paths of the directories above it, so it never fires for a relative link. The walk only stops when the OS refuses to resolve the path (ELOOP, after 32 links on macOS), visiting every path through the link graph up to that depth.
The only workaround I've found, and what the Metro PR does, is to [ignore] the linked packages under every node_modules, eg **/node_modules/metro*/**. That also hides any unrelated npm package that happens to match (in Metro's case, metro-memory-fs).
Activity
[flow] Share the crawl file filter between full and subdirectory craw…
[flow] Report each crawled file once (#9533)
[flow] Fix file crawl hanging on pnpm workspace links (#9534)
[flow] Stop the file crawl at symlink cycles (meta#9535)