Skip to content

Unbounded globbing leads to "freeze" during pod install #2479

@ephemer

Description

@ephemer

Hello, and thank you for your work on this project! 🙂

I have been trying to understand a weird bug whereby pod install no longer works for me from RN >= 0.74. It just appears to freeze and do nothing. I left it for 30mins and nothing happened.

I finally tracked this down to the npx @react-native-community/cli config call performed during install. After some log debugging it turns out the "freeze" occurs during globbing while searching for the iOS Podfile.

We have a submodule containing native code that is very deeply nested (with its own native build system, dependencies, their build artefacts, etc.). fast-glob seems to get stuck looking in that deeply nested directory structure (maybe there's even a cycle somewhere due to symlinks – I'm not sure). In any case, it seems like the most likely case by far is that Podfile can be found in ${PROJECT_ROOT}/ios/Podfile. It seems very unlikely that it will be found in a deeply nested directory somewhere – if it will be found anywhere other than that default location in the first place.

The following diff solved my problem, and I believe it'd generally be a good idea to put an upper bound on the depth of the search:

diff --git a/node_modules/@react-native-community/cli-platform-apple/build/config/findAllPodfilePaths.js b/node_modules/@react-native-community/cli-platform-apple/build/config/findAllPodfilePaths.js
index e82bcee..3d789cb 100644
--- a/node_modules/@react-native-community/cli-platform-apple/build/config/findAllPodfilePaths.js
+++ b/node_modules/@react-native-community/cli-platform-apple/build/config/findAllPodfilePaths.js
@@ -32,7 +32,8 @@ const GLOB_EXCLUDE_PATTERN = ['**/@(Pods|node_modules|Carthage|vendor)/**'];
 function findAllPodfilePaths(cwd) {
   return _fastGlob().default.sync('**/Podfile', {
     cwd: (0, _cliTools().unixifyPaths)(cwd),
-    ignore: GLOB_EXCLUDE_PATTERN
+    ignore: GLOB_EXCLUDE_PATTERN,
+    deep: 10,
   });
 }
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions