Publishing manage Expo app intermittently fails, out of memory

Hey–

We’ve been having intermittent failures in publishing our managed Expo app via Circle (topic in Expo forum here.

While this may also be an issue on Expo’s side, it seems like there may be a memory usage issue on Circle’s side. We’re limiting our job to 2 workers and executing on Docker Medium instances. Is there a Circle configuration we’re missing here?

A snippet of our Circle config.yml (where the various deploy-<x> yarn scripts just run expo publish ...):

version: 2.1
orbs:
  node: circleci/node@1.1.6
commands:
  expo-publish:
    description: "Publish an OTA update via Expo"
    parameters:
      yarn-script:
        type: string
    steps:
      - checkout
      - restore_cache:
          keys:
            - mobile-yarn-dependencies-{{ checksum "mobile/yarn.lock" }}
            - mobile-yarn-dependencies-
      - run:
          name: Install dependencies
          command: cd mobile && yarn --frozen-lockfile --cache-folder ~/.cache/yarn
      - run:
          name: Authenticate to Expo
          command: npx expo-cli login --non-interactive -u $EXPO_USERNAME
      - run:
          name: Publish to Expo
          no_output_timeout: 30m
          command: cd mobile && yarn << parameters.yarn-script >>
      - save_cache:
          key: mobile-yarn-dependencies-{{ checksum "mobile/yarn.lock" }}
          paths:
            - ~/.cache/yarn
jobs:
  test:
    executor:
      name: node/default
      tag: "12.14.1"
    steps:
      - checkout
      - restore_cache:
          keys:
            - mobile-yarn-dependencies-{{ checksum "mobile/yarn.lock" }}
            - mobile-yarn-dependencies-
      - run: cd mobile && yarn --frozen-lockfile --cache-folder ~/.cache/yarn && yarn test --maxWorkers=2
      - save_cache:
          key: mobile-yarn-dependencies-{{ checksum "mobile/yarn.lock" }}
          paths:
          - ~/.cache/yarn
  deploy-android-to-staging:
    executor:
      name: node/default
      tag: "12.14.1"
    steps:
      - expo-publish:
          yarn-script:  deploy-android-staging
  deploy-ios-to-staging:
    executor:
      name: node/default
      tag: "12.14.1"
    steps:
      - expo-publish:
          yarn-script: deploy-ios-staging
workflows:
  test:
    jobs:
      - test:
          filters:
            branches:
              ignore:
                - ios-staging
                - android-staging
  deploy:
    jobs:
      - deploy-ios-to-staging:
          filters:
            branches:
              only:
                - ios-staging
      - deploy-android-to-staging:
          filters:
            branches:
              only:
                - android-staging

A sample of the errors we’re seeing (more detail in the topic in the Expo forum here):

[05:10:56] - Expo SDK: 39.0.0
[05:10:56] - Release channel: <redacted>
[05:10:56] - Workflow: Managed

[05:10:56] Building optimized bundles and generating sourcemaps...
[05:10:58] Starting Metro Bundler.
[05:10:58] Building iOS bundle
[05:16:44] Finished building JavaScript bundle in 338554ms.
[05:16:44] Building Android bundle
[05:19:41] events.js:200
[05:19:41]       throw er; // Unhandled 'error' event
[05:19:41]       ^
[05:19:41] 
[05:19:41] Error: write EPIPE
[05:19:41]     at ChildProcess.target._send (internal/child_process.js:806:20)
[05:19:41]     at ChildProcess.target.send (internal/child_process.js:676:19)
[05:19:41]     at ChildProcessWorker.send (/home/circleci/project/mobile/node_modules/metro/node_modules/jest-worker/build/workers/ChildProcessWorker.js:286:17)
[05:19:41]     at WorkerPool.send (/home/circleci/project/mobile/node_modules/metro/node_modules/jest-worker/build/WorkerPool.js:32:34)
[05:19:41]     at Farm._process (/home/circleci/project/mobile/node_modules/metro/node_modules/jest-worker/build/Farm.js:129:10)
[05:19:41]     at onEnd (/home/circleci/project/mobile/node_modules/metro/node_modules/jest-worker/build/Farm.js:122:12)
[05:19:41]     at ChildProcessWorker._onProcessEnd (/home/circleci/project/mobile/node_modules/metro/node_modules/jest-worker/build/workers/ChildProcessWorker.js:280:14)
[05:19:41]     at ChildProcessWorker.onMessage (/home/circleci/project/mobile/node_modules/metro/node_modules/jest-worker/build/workers/ChildProcessWorker.js:220:14)
[05:19:41]     at ChildProcess.emit (events.js:223:5)
[05:19:41]     at emit (internal/child_process.js:876:12)
[05:19:41] Emitted 'error' event on ChildProcess instance at:
[05:19:41]     at internal/child_process.js:810:39
[05:19:41]     at processTicksAndRejections (internal/process/task_queues.js:76:11) {
[05:19:41]   errno: 'EPIPE',
[05:19:41]   code: 'EPIPE',
[05:19:41]   syscall: 'write'
[05:19:41] }
[05:19:41] 
[05:19:42] socket hang up
[05:19:42] Error: socket hang up
    at connResetException (internal/errors.js:570:14)
    at Socket.socketOnEnd (_http_client.js:440:23)
    at Socket.emit (events.js:228:7)
    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Exited with code exit status 1
CircleCI received exit code 1
[06:41:29] Building optimized bundles and generating sourcemaps...
[06:41:30] Starting Metro Bundler.
[06:41:30] Building iOS bundle
[06:42:13] node_modules/react-native/Libraries/Components/TextInput/TextInputState.js: ENOMEM: not enough memory, read
[06:42:13] Failed building JavaScript bundle.
[06:42:13] node_modules/react-native/Libraries/Components/TextInput/TextInputState.js: ENOMEM: not enough memory, read
[06:42:14] Packager URL http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?dev=false&minify=true&hot=false&platform=ios returned unexpected code 500. Please open your project in the Expo app and see if there are any errors. Also scroll up and make sure there were no errors or warnings when opening your project.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Exited with code exit status 1
CircleCI received exit code 1

Thanks in advance!

1 Like

Hi,

Please SSH into a container and run the commands manually and see if you get the same error.

Also, you can record the memory usage by following the below article.

Regards,
Pawan Bahuguna

We are having the same intermittent issue in our builds. It’s failing a lot lately.

@Pawan thanks for the advice!

We went ahead and tried recording the memory usage, and are consistently getting values just below 4300000000 bytes, or 4.3 GB. We’re running our jobs on Docker Medium executors, which are 4 GB. Any advice on why/how we’re hitting almost 4.3 GB on memory usage?