Expo react-native error: Error: Request failed with status code 504

I’m struggling to get ci work for my expo react-native. I have following guidelines from the official expo tutorial to deploy with circleci. Here is my config.yml file:

version: 2
publish: &publish
  working_directory: ~/loplop-native
  docker:
    - image: circleci/node:12.14.0
  steps:
    - checkout
    - restore_cache:
        name: Restore yarn package cache
        key: v1-cache-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }}-{{ arch }}
    - run:
        name: Install dependencies
        command: yarn install --frozen-lockfile
    - save_cache:
        name: Save yarn package cache
        paths:
          - ~/.cache/yarn
        key: v1-cache-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }}-{{ arch }}
    - run:
        name: Login into Expo
        command: (yes || true ) | sudo npx expo login --non-interactive -u $EXPO_USERNAME -p $EXPO_PASSWORD
    - run:
        name: Save current branch name to an env variable
        command: |
          if [ "${CIRCLE_BRANCH}" == "master" ]; then
            echo 'export EXPO_RELEASE_CHANNEL="default"' >> $BASH_ENV
          else
            echo 'export EXPO_RELEASE_CHANNEL=$CIRCLE_BRANCH' >> $BASH_ENV
          fi
    - run:
        name: Publish to Expo
        command: npx expo publish --non-interactive --max-workers 1 --release-channel $EXPO_RELEASE_CHANNEL

jobs:
  build_and_test:
    docker:
      - image: circleci/node:12.14.0
    steps:
      - checkout
      - restore_cache:
          name: Restore yarn package cache
          key: v1-cache-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }}-{{ arch }}
      - run:
          name: Install dependencies
          command: yarn install --frozen-lockfile
      - save_cache:
          name: Save yarn package cache
          paths:
            - ~/.cache/yarn
          key: v1-cache-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }}-{{ arch }}
      #- run:
      #    name: Run tests
      #    command: yarn test:js --ci
      - run:
          name: Run linting
          command: yarn lint

  publish_to_expo:
    <<: *publish

workflows:
  version: 2
  workflow:
      jobs:
        - build_and_test
        - publish_to_expo:
            filters:
              branches:
                ignore: gh-pages

Everything works up until the login command which then attempts to install globally the expo-cli dependency. Although the dependency seems to have installed well, the process exits with the error in the title. Here is the full report of the login + expo-cli global install (see error at the end of the script):

This command requires Expo CLI.
Do you want to install it globally [Y/n]? y
Installing the package 'expo-cli'...
[..................] \ fetchMetadata: sill resolveWithNewModule expo-cli@3.20.9[0m
[..................] - fetchMetadata: sill resolveWithNewModule expo-cli@3.20.9
[..................] - fetchMetadata: sill resolveWithNewModule expo-cli@3.20.9
[..................] - fetchMetadata: sill resolveWithNewModule expo-cli@3.20.9
[..................] \ fetchMetadata: sill resolveWithNewModule moment@2.26.0 c
[..................] \ fetchMetadata: sill resolveWithNewModule fs-extra@8.1.0K
[..................] - loadDep:once: sill resolveWithNewModule pump@3.0.0 check
[..................] - fetchMetadata: sill resolveWithNewModule path-exists@3.0
[..................] / fetchMetadata: sill resolveWithNewModule @babel/highligh
[..................] \ loadDep:lodash: sill resolveWithNewModule @babel/helper-
[..................] - fetchMetadata: sill resolveWithNewModule object.assign@4
[..................] / loadDep:semver: sill resolveWithNewModule object-keys@1.
[..................] / fetchMetadata: sill resolveWithNewModule @babel/helper-r
[..................] | fetchMetadata: sill resolveWithNewModule regenerator-run
[..................] | loadDep:xmldom: sill resolveWithNewModule signal-exit@3.
[..................] - fetchMetadata: sill resolveWithNewModule to-regex-range@
[..................] / fetchMetadata: sill resolveWithNewModule sax@1.2.4 check
[..................] - loadDep:type-is: sill resolveWithNewModule mime-db@1.44.
[..................] \ fetchMetadata: sill resolveWithNewModule zen-observable-
[..................] / fetchMetadata: sill resolveWithNewModule is-extendable@0
[..................] | fetchMetadata: sill resolveWithNewModule isobject@2.1.0K
[..................] - fetchMetadata: sill resolveWithNewModule is-data-descrip
[#.................] / fetchMetadata: sill resolveWithNewModule emitter-compone
[#.................] | fetchMetadata: sill resolveWithNewModule emitter-compone
[#.................] - fetchMetadata: sill resolveWithNewModule @expo/osascript
[#.................] | loadDep:@babel/plugin-syntax-jsx: sill resolveWithNewMod
[#.................] - fetchMetadata: sill resolveWithNewModule @types/color-na
[#.................] | fetchMetadata: sill resolveWithNewModule color-name@1.1.
[#.................] | fetchMetadata: sill resolveWithNewModule @expo/ngrok-bin
[#.................] | fetchMetadata: sill resolveWithNewModule @expo/ngrok-bin
[#.................] / fetchMetadata: sill resolveWithNewModule @expo/ngrok-bin
[#.................] - fetchMetadata: sill resolveWithNewModule tunnel-agent@0.
[#.................] / fetchMetadata: sill resolveWithNewModule exec-async@2.2.
[#.................] - fetchMetadata: sill resolveWithNewModule p-finally@1.0.0
[#.................] / fetchMetadata: sill resolveWithNewModule @types/source-l
[#.................] \ fetchMetadata: sill resolveWithNewModule typedarray@0.0.
[#.................] - loadDep:postcss: sill resolveWithNewModule uniq@1.0.1 ch
[#.................] - fetchMetadata: sill resolveWithNewModule @jimp/core@0.9.
[#.................] | loadDep:xtend: sill resolveWithNewModule ieee754@1.1.13K
[#.................] | loadDep:timm: sill resolveWithNewModule @jimp/plugin-sha
[#.................] - loadDep:object-assign: sill resolveWithNewModule ini@1.3
[#.................] | fetchMetadata: sill resolveWithNewModule entities@2.0.2K
[#.................] / fetchMetadata: sill resolveWithNewModule argparse@1.0.10
[#.................] / loadDep:uniq: sill resolveWithNewModule postcss-selector
[#.................] / loadDep:util.promisify: sill resolveWithNewModule html-c
[#.................] | fetchMetadata: sill resolveWithNewModule js-tokens@3.0.2
[#.................] | loadDep:to-regex: sill resolveWithNewModule is-glob@3.1.
[#.................] \ fetchMetadata: sill resolveWithNewModule emojis-list@2.1
[#.................] \ loadDep:webpack-sources: sill resolveWithNewModule schem
[#.................] - fetchMetadata: sill resolveWithNewModule memory-fs@0.5.0
[#.................] | loadDep:safe-buffer: sill resolveWithNewModule sha.js@2.
[#.................] \ fetchMetadata: sill resolveWithNewModule to-arraybuffer@
[#.................] / fetchMetadata: sill resolveWithNewModule regenerator-run
[#.................] \ loadDep:uuid: sill resolveWithNewModule toposort@2.0.2 c
[#.................] - loadDep:tslib: sill resolveWithNewModule callsite@1.0.0K
[#.................] - loadDep:ipaddr.js: sill resolveWithNewModule ansi-regex@
[#.................] / loadDep:once: sill resolveWithNewModule json-parse-even-
[#.................] | fetchMetadata: sill resolveWithNewModule @npmcli/ci-dete
[#.................] - fetchMetadata: sill resolveWithNewModule thenify@3.3.0 c
[#.................] \ fetchMetadata: sill resolveWithNewModule buffer-indexof@
[#.................] | fetchMetadata: sill resolveWithNewModule mime@2.4.5 chec
[##................] / fetchMetadata: sill resolveWithNewModule defaults@1.0.3K
[###...............] - fetchMetadata: sill resolveWithNewModule kleur@3.0.3 che
[###...............] / fetchMetadata: sill resolveWithNewModule type-fest@0.11.
[#######...........] - diffTrees: sill install generateActionsToTake
[#######...........] - extract:expo-cli: verb lock using /root/.npm/_locks/stag
[#######...........] | extract:semver: sill extract @babel/helper-validator-ide
[#######...........] / extract:readdir-scoped-modules: sill extract glob@7.1.6K
[########..........] \ extract:finalhandler: sill extract bytes@3.1.0
[########..........] - extract:braces: sill extract ajv@6.12.2e-lax@^3.0
[#########.........] | extract:@babel/preset-env: sill extract @babel/helper-bu
[#########.........] | extract:class-utils: sill extract deep-equal@^1.0.1 extr
[#########.........] | extract:jsesc: sill extract source-map@0.5.7over@
[##########........] - extract:browserify-zlib: sill extract process@0.11.10[KK
[##########........] | extract:lowercase-keys: sill extract lower-case@^1.1.1 e
[###########.......] / extract:figgy-pudding: sill extract encodeurl@1.0.20m
[###########.......] - extract:binary-extensions: sill extract aws4@1.10.0mK
[############......] - extract:ajv: sill extract ajv@^5.2.2 extracted to /usr/l
[############......] / extract:graphql: sill extract graphql@0.13.2 extracted t
[############......] \ extract:lodash: sill extract lodash@4.17.15 extracted to
[############......] / extract:@expo/ngrok-bin-linux-x64: sill extract @expo/ng
[############......] \ extract:@types/lodash: sill extract @types/lodash@^4.14.
[############......] / extract:rxjs: sill extract rxjs@^6.4.0 extracted to /usr
[############......] - extract:rxjs: sill extract rxjs@^5.5.2 extracted to /usr
[############......] - extract:rxjs: sill extract rxjs@^5.5.2 extracted to /usr
[############......] - extract:rxjs: sill extract rxjs@^5.5.2 extracted to /usr
[############......] - finalize:etag: sill finalize /usr/local/lib/node_modules
[############......] / finalize:@jimp/jpeg: sill finalize /usr/local/lib/node_m
[############......] - finalize:public-encrypt: sill finalize /usr/local/lib/no
[############......] \ refresh-package-json:@babel/parser: sill refresh-package
[############......] - refresh-package-json:watchpack: sill refresh-package-jso
[############......] - refresh-package-json:domutils: sill refresh-package-json
[############......] / refresh-package-json:uuid: sill refresh-package-json /us
[############......] / refresh-package-json:is-accessor-descriptor: sill refres
[############......] \ refresh-package-json:caller-callsite: sill refresh-packa
[############......] / preinstall:postcss-normalize-positions: info lifecycle i
[############......] - build:isexe: sill linkStuff isexe@2.0.0 is installed int
[############......] \ install:co: info lifecycle co@4.6.0~install: co@4.6.0m
[############......] / install:webpack-dev-server: info lifecycle webpack-dev-s
[############......] \ postinstall:pify: info lifecycle pify@4.0.1~postinstall:ass@2.1.
Expo CLI installed. You can run `expo --help` for instructions.it@2.0.
[01:37:00] Request failed with status code 504
[01:37:00] Error: Request failed with status code 504
    at createError (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/expo-cli/node_modules/axios/lib/adapters/http.js:237:11)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1184:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

Exited with code exit status 1
CircleCI received exit code 1

I am new to circleci, I have been looking every where on the net for some help. Any suggetion would be greatly appreciated.

Hey, you probably have figure this out by now, but I want to give a suggestion for others searching for this.

I was having intermittent fails and although the build itself is done in expo, it looks like a large blob of file is loaded in circle ci instance as build progresses. So increasing the machine size worked for me.

Just add inside your ‘publish_to_expo’ job:

- publish_to_expo:
    resource_class: medium+

Hope it helps.