[exp CLI] exp login hangs in Bitbucket pipelines

Hi,

we experience a strange behaviour when trying to use exp CLI with bitbucket pipelines. Once in a while our build hangs, always while executing
node ./node_modules/exp/bin/exp.js login -u $EXPO_LOGIN -p $EXPO_PASSWORD
The output we see in Bitbucket console is:

node ./node_modules/exp/bin/exp.js login -u $EXPO_LOGIN -p $EXPO_PASSWORD
3s
+ node ./node_modules/exp/bin/exp.js login -u $EXPO_LOGIN -p $EXPO_PASSWORD
Success. You are now logged in as letsgig.

but the command doesn’t seem to finish and this step lasts forever.
We’re not sure if it’s an issue with exp or bitbucket infrastructure, but maybe you could help us narrow it down. We tried using the docker image (node:9.11-alpine) - which is used in the pipeline - locally and running exp login multiple times - it worked. Any suggestions how to debug it? I went through the login method code and there’s not much which can go wrong.

Tried running diagnostics report but encountered an error:

node ./node_modules/exp/bin/exp.js diagnostics
[12:53:43] Generating diagnostics report...
[12:53:43] You can join our slack here: https://slack.expo.io/.
Environment:
  OS: Linux 4.14
  Node: 9.11.2
  Yarn: 1.5.1
  npm: 5.6.0
  Watchman: Not Found
  Xcode: N/A
  Android Studio: Not Found
Packages: (wanted => installed)
  expo: ^28.0.0 => 28.0.0
  react: 16.3.1 => 16.3.1
  react-native: https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz => 0.55.4
Diagnostics report:
|
/
-[12:53:45] Request failed with status code 500
[12:53:45] Error: Request failed with status code 500
    at createError (/opt/atlassian/pipelines/agent/build/node_modules/xdl/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/opt/atlassian/pipelines/agent/build/node_modules/xdl/node_modules/axios/lib/core/settle.js:18:12)
    at IncomingMessage.handleStreamEnd (/opt/atlassian/pipelines/agent/build/node_modules/xdl/node_modules/axios/lib/adapters/http.js:191:11)
    at IncomingMessage.emit (events.js:185:15)
    at endReadableNT (_stream_readable.js:1106:12)
    at process._tickCallback (internal/process/next_tick.js:178:19)

hi @letsgig,

thanks for writing in. we’ve seen reports in the past with certain exp commands hanging, but it’s usually because we spin off some background processes, and wait for them to terminate. i’m not really sure what’s going on with exp login though, since we aren’t spinning up any additional processes, and the login routine appears to have been completed :confused:

if you are able to find some kind of repro of the issue, we’d be more than happy to dig into it if you post it on github issues (Issues · expo/expo · GitHub). wish i had a better answer for you here, sorry :frowning:

hi @letsgig
Could you try exp logout before exp login to see if that fixes your problem?

There was actually a bug with the --non-interactive flag that we’ve since fixed but have yet to release in exp (https://github.com/expo/exp/pull/105). But in future releases, the terminal should no longer hang if the --non-interactive flag is passed, even if you were previously logged in.

https://github.com/expo/expo/issues/1855

I will try that today. Thanks. We’re also in contact with bitbucket, but no success so far.

Still no joy:

node ./node_modules/exp/bin/exp.js logout && echo "Command excuted"
1s
+ node ./node_modules/exp/bin/exp.js logout && echo "Command excuted"
[14:01:54] Success.
Command excuted
node ./node_modules/exp/bin/exp.js login -u $EXPO_LOGIN -p $EXPO_PASSWORD && echo "Command excuted"
2s
+ node ./node_modules/exp/bin/exp.js login -u $EXPO_LOGIN -p $EXPO_PASSWORD && echo "Command excuted"
Success. You are now logged in as letsgig.

As you can see we added "Command excuted" which never arrives after login.

Which version of exp are you using?

1 Like

hey @letsgig, could you try upgrading to the newest exp and adding the non-interactive flag to login (ie) exp login -u <USER> -p <PASSWORD> --non-interactive

Tried. Same story :frowning:

+ node ./node_modules/exp/bin/exp.js --version
56.0.0
+ node ./node_modules/exp/bin/exp.js logout && echo "Command excuted"
[10:19:35] Success.
Command excuted
node ./node_modules/exp/bin/exp.js login -u $EXPO_LOGIN -p $EXPO_PASSWORD --non-interactive && echo "Command excuted"
1s
+ node ./node_modules/exp/bin/exp.js login -u $EXPO_LOGIN -p $EXPO_PASSWORD --non-interactive && echo "Command excuted"
Success. You are now logged in as letsgig.

Also experiencing this issue in a VSTS environment

@motix Are Docker images used in your VSTS env?

@quinlanj We forked expo cli project, added some logs and found a socket hanging after login has been performed. Unfortunately, it doesn’t say much and we’re not node ninjas so if you have an idea what we could print to the console which would help us pinpoint what exactly hangs at the end, please do.

This is the diff (1 extra element) of the logs when login finished with success and failure:

Socket {
    connecting: false,
    _hadError: false,
    _handle:
     Pipe {
       writeQueueSize: 0,
       owner: [Circular],
       onread: [Function: onread],
       reading: true },
    _parent: null,
    _host: null,
    _readableState:
     ReadableState {
       objectMode: false,
       highWaterMark: 16384,
       buffer: [Object],
       length: 0,
       pipes: null,
       pipesCount: 0,
       flowing: false,
       ended: false,
       endEmitted: false,
       reading: true,
       sync: false,
       needReadable: true,
       emittedReadable: false,
       readableListening: false,
       resumeScheduled: false,
       destroyed: false,
       defaultEncoding: 'utf8',
       awaitDrain: 0,
       readingMore: false,
       decoder: null,
       encoding: null },
    readable: true,
    domain: null,
    _events:
     { end: [Object],
       finish: [Function: onSocketFinish],
       _socketEnd: [Function: onSocketEnd],
       pause: [Function],
       data: [Function: onData] },
    _eventsCount: 5,
    _maxListeners: undefined,
    _writableState:
     WritableState {
       objectMode: false,
       highWaterMark: 16384,
       finalCalled: false,
       needDrain: false,
       ending: false,
       ended: true,
       finished: false,
       destroyed: false,
       decodeStrings: false,
       defaultEncoding: 'utf8',
       length: 0,
       writing: false,
       corked: 0,
       sync: true,
       bufferProcessing: false,
       onwrite: [Function: bound onwrite],
       writecb: null,
       writelen: 0,
       bufferedRequest: null,
       lastBufferedRequest: null,
       pendingcb: 0,
       prefinished: false,
       errorEmitted: false,
       bufferedRequestCount: 0,
       corkedRequestsFree: [Object] },
    writable: false,
    allowHalfOpen: false,
    _bytesDispatched: 0,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: null,
    _server: null,
    fd: 0,
    [Symbol(asyncId)]: 62,
    [Symbol(bytesRead)]: 0,
    [Symbol(keypress-decoder)]:
     StringDecoder {
       encoding: 'utf8',
       fillLast: [Function: utf8FillLast],
       lastNeed: 0,
       lastTotal: 0,
       lastChar: <Buffer 00 00 00 00> },
    [Symbol(escape-decoder)]: {} },
2 Likes

hey @letsgig, thanks for reporting back. how easy is it to get this hanging error? if its not too much trouble, since you’ve already forked exp could you make the following changes to your fork and run the usual exp login command you normally run?

https://github.com/expo/expo-cli/commit/bb9d0e5874249e92ba0e1c54110d58440da71ad6

this should port in a package called ‘why-is-node-running’ and should print out some logs showing where node is hanging (kind of noisy, but might show smth useful)

edit: it should dump some logs after 5 seconds
edit1: if you forked the project from https://github.com/expo/exp , the same project is rooted to the one i linked, at https://github.com/expo/expo-cli/tree/master/packages/exp

Hi,
Ì am observing the same issue on vsts build pipeline.

I ended up ‘hacking’ a solution, temporary, I hope.

So here is the command:

( cmdpid=$BASHPID; (sleep 10; kill $cmdpid) && exec expo-cli login -u <LOGIN> -p <PASSWORD> --non-interactive ) || exit 0

It is basically saying :

wrap the “expo login” command inside a timeout of 10 seconds, and always returns a successful result (status code 0)

Hi again, Bitbucket team advised us to try out the latest node version (10.10 currently). Previously we used versions 8 and 9. So far we haven’t had any failures :slight_smile: It suggests some problems with node then.

2 Likes

Great :grinning: ! I works on my end: Used node 10 fixes the issue on vsts as well

Thanks @letsgig

Is there any other solution other than changing the node version? Our app is currently locked to node 8.10 and cannot be upgraded to 10+.

@la1255 you can try this solution:

[exp CLI] exp login hangs in Bitbucket pipelines - #13 by ziied

Thanks, finally tried it. Works well :+1:

Great,

Please this is more of a hackish solution. If you have the opportunity to use node 10, use it :slight_smile:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.