FormidableLabs / appr

Open React Native PR Builds instantly on device
MIT License
381 stars 38 forks source link

exp socket hang up #8

Closed aurbina83 closed 7 years ago

aurbina83 commented 7 years ago

All of my builds fail with CircleCI at

[exp]  ERROR  watch /home/ubuntu/citest2/node_modules/react-native-maps/lib/android/build/tmp/expandedArchives/classes.jar_rvtuwwbhztnbbkxi8oruhd9v/android/support/v4/hardware/fingerprint ENOSPC

I'm guessing because of the watch command? Here is the full log.

if [ "$CI_PULL_REQUEST" != "" ]; then yarn appr; fi
yarn appr v0.27.5
$ appr
[appr] Logging into Expo...
There is a new version of exp available (44.0.0).
You are currently using exp 36.0.0
Run `npm install -g exp` to get the latest version

Success.
[appr] Logged into Expo.
[appr] Preparing project for publish...
[appr] Publishing project into Expo.
There is a new version of exp available (44.0.0).
You are currently using exp 36.0.0
Run `npm install -g exp` to get the latest version
[exp] Making sure project is set up correctly...
-[exp] Warning: Not using the Expo fork of react-native. See https://docs.getexponent.com/.

-[exp] Warning: 'react' peer depencency missing. Run `npm ls` in /home/ubuntu/citest2 to see full warning.
[exp] 
[exp] If there is an issue running your project, please run `npm install` in /home/ubuntu/citest2 and restart.

[exp] Your project looks good!
[exp] Unable to find an existing exp instance for this directory, starting a new one...
[exp] Warning: Not using the Expo fork of react-native. See https://docs.getexponent.com/.
[exp] Warning: 'react' peer depencency missing. Run `npm ls` in /home/ubuntu/citest2 to see full warning.
[exp] 
[exp] If there is an issue running your project, please run `npm install` in /home/ubuntu/citest2 and restart.
[exp] Starting React Native packager...
[exp] Scanning 826 folders for symlinks in /home/ubuntu/citest2/node_modules (9ms)
[exp] 
[exp] Running packager on port 19001
[exp] 
[exp] 
[exp] 
[exp] Looking for JS files in
[exp]    /home/ubuntu/citest2 
[exp] 
[exp] 
[exp] 
[exp] 
[exp] React packager ready.
[exp] 
[exp] 
[exp] 
[exp] Publishing...
[exp]  ERROR  watch /home/ubuntu/citest2/node_modules/react-native-maps/lib/android/build/tmp/expandedArchives/classes.jar_rvtuwwbhztnbbkxi8oruhd9v/android/support/v4/hardware/fingerprint ENOSPC
[exp] 
[exp] {"code":"ENOSPC","errno":"ENOSPC","syscall":"watch /home/ubuntu/citest2/node_modules/react-native-maps/lib/android/build/tmp/expandedArchives/classes.jar_rvtuwwbhztnbbkxi8oruhd9v/android/support/v4/hardware/fingerprint","filename":"/home/ubuntu/citest2/node_modules/react-native-maps/lib/android/build/tmp/expandedArchives/classes.jar_rvtuwwbhztnbbkxi8oruhd9v/android/support/v4/hardware/fingerprint"}
[exp] Error: watch /home/ubuntu/citest2/node_modules/react-native-maps/lib/android/build/tmp/expandedArchives/classes.jar_rvtuwwbhztnbbkxi8oruhd9v/android/support/v4/hardware/fingerprint ENOSPC
[exp]     at exports._errnoException (util.js:1022:11)
[exp]     at FSWatcher.start (fs.js:1429:19)
[exp]     at Object.fs.watch (fs.js:1456:11)
[exp]     at NodeWatcher.watchdir (/home/ubuntu/citest2/node_modules/jest-haste-map/node_modules/sane/src/node_watcher.js:150:20)
[exp]     at Walker.<anonymous> (/home/ubuntu/citest2/node_modules/jest-haste-map/node_modules/sane/src/node_watcher.js:374:12)
[exp]     at emitTwo (events.js:106:13)
[exp]     at Walker.emit (events.js:191:7)
[exp]     at /home/ubuntu/citest2/node_modules/walker/lib/walker.js:69:16
[exp]     at go$readdir$cb (/home/ubuntu/citest2/node_modules/graceful-fs/graceful-fs.js:149:14)
[exp]     at FSReqWrap.oncomplete (fs.js:123:15)
[exp] 
[exp] socket hang up
Error: socket hang up
    at createHangUpError (_http_client.js:254:15)
    at Socket.socketOnEnd (_http_client.js:346:23)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
/home/ubuntu/citest2/node_modules/appr/index.js:22
      throw new Error('Failed to publish package to Expo');
      ^

Error: Failed to publish package to Expo
    at publishError (/home/ubuntu/citest2/node_modules/appr/index.js:22:13)
    at ChildProcess.child.on.code (/home/ubuntu/citest2/node_modules/appr/scripts/spawn.js:16:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
error Command failed with exit code 1.

if [ "$CI_PULL_REQUEST" != "" ]; then yarn appr; fi returned exit code 1

Action failed: if [ "$CI_PULL_REQUEST" != "" ]; then yarn appr; fi
aurbina83 commented 7 years ago

I was able to bypass this issue by adding nonPersistant to the app.json

{
  "expo": {
    "sdkVersion": "20.0.0",
    "packagerOpts": {
      "nonPersistent": "--nonPersistent"
    }
  }
}
Atheane commented 7 years ago

Thank you so much for sharing.

conrad-vanl commented 7 years ago

Should this be included in the project readme for setup? I can confirm that on a new CRNA project, setup fails without this option in app.json (with Travis CI atleast).

AndrewSouthpaw commented 5 years ago

For future googlers who came upon this problem... We tried the nonPersistent configuration options (both "nonPersistent": "--nonPersistent" and "nonPersistent": true) inpackagerOpts` but none of them worked.

Try this: echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Long version

We tried the nonPersistent configuration options in packagerOpts but none of them worked.

The ENOSPC error code was critical in solving the problem. It was fixed with this line:

echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

inotify is the system that watchman (a file watcher made by Facebook) uses, and watchman is used by Expo. It appears for Travis we would hit the limit of watches and report we had no more space, but actually we just ran out of file descriptors. The line above increases that amount. More here. You could also probably try installing watchman, but that seemed pretty difficult to do on Ubuntu and the above command worked for us so whatever.

In our particular case, we were using default Travis builds, which it turns out runs on Ubuntu 14. It didn't particularly like the command above, so we switched to using Ubuntu 16 (Xenial) and had to enable sudo mode. So, for Travis folks, here's the salient details in our .travis.yml file:

dist: xenial

# We needed to specify PostgreSQL 10 once we switched to Ubuntu 16
# you might need this as well
addons:
  postgresql: "10"

# then add the script however you want

We also noticed that it would choke when we used the && with the command, so we split it into two separate operations:

    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
    sudo sysctl -p

Hope this is helpful to other people!