Skip to content

Adding the package react-native-clean-project to the dependencies makes the config command never exit #567

Description

@Pita

Environment

System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
Memory: 1.04 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.14.1 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.4 => 0.60.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Description

The config command gives output but never exits.

Reproducible Demo

react-native init test2
cd test2
yarn add -D react-native-clean-project
node ./node_modules/react-native/cli.js config <-- PRODUCES OUTPUT BUT GETS STUCK AND NEVER EXISTS

Reason for react/react-native#25743

Activity

  1. added
    bugSomething isn't working
    on Jul 19, 2019
  2. thymikee commented on Jul 19, 2019

    @thymikee
    Member

    That's odd. I can reproduce this. Seems like commander refuses to exit cleanly, likely because of some leak (possibly in the mentioned library). In the meantime, here's a workaround (to apply e.g. with patch-package):

    diff --git a/packages/cli/src/cliEntry.js b/packages/cli/src/cliEntry.js
    index b2342de3..d7b2c1d1 100644
    --- a/packages/cli/src/cliEntry.js
    +++ b/packages/cli/src/cliEntry.js
    @@ -114,6 +114,7 @@ const addCommand = (command: CommandT, ctx: ConfigT) => {
           try {
             assertRequiredOptions(options, passedOptions);
             await command.func(argv, ctx, passedOptions);
    +        process.exit(0);
           } catch (error) {
             handleError(error);
           }
    
  3. Pita commented on Jul 19, 2019

    @Pita
    Author

    @thymikee Thanks for the quick response!

    Managed to fix it in the library: https://github.com/pmadruga/react-native-clean-project/pull/23/files

    I guess a simple json file for defining these commands would better than running a js file of untrusted code. But I guess thats no simple migration. In the meanwhile process.exit() should mitigate the worst

  4. thymikee commented on Jul 19, 2019

    @thymikee
    Member

    Glad you fixed the issue so quickly :)

    guess a simple json file for defining these commands would better than running a js file of untrusted code

    That's a valid concern, and this example shows that the current mechanism can be exploited. Having JS-based config makes it hard to avid. We could require users to explicitly define commands and get rid of auto-discovery, but not sure what's the best path forward here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions