@@ -17,6 +17,8 @@ export const EMULATOR_HOST_IPS = [
1717 '10.0.3.2' , // Genymotion localhost ip
1818] ;
1919
20+ let reportedAdbConnError = false ;
21+
2022export function createAdbClient ( ) {
2123 const client = adb . createClient ( {
2224 port : process . env [ 'ANDROID_ADB_SERVER_PORT' ]
@@ -43,13 +45,14 @@ export function createAdbClient() {
4345 // We listen for errors and report them. This only happens if adbkit completely
4446 // fails to handle or listen to a connection error. We'd rather report that than crash.
4547 client . on ( 'error' , ( e ) => {
46- if ( isErrorLike ( e ) && e . code === 'ENOENT' ) {
47- // No ADB available - that's fine, not notable at all
48- return ;
48+ // We only report the first error though. Note that most errors will also surface
49+ // elsewhere, e.g. as a rejection from the relevant promise. This is mostly here
50+ // for weird connection errors that might appear async elsewhere.
51+ if ( ! reportedAdbConnError ) {
52+ reportedAdbConnError = true ;
53+ console . log ( 'ADB connection error:' , e . message ?? e ) ;
54+ logError ( e ) ;
4955 }
50-
51- console . log ( 'ADB client error:' , e . message ?? e ) ;
52- logError ( e ) ;
5356 } ) ;
5457
5558 return client ;
@@ -105,6 +108,7 @@ export const getConnectedDevices = batchCalls(
105108 e . code === 'ENOENT' || // No ADB available
106109 e . code === 'EACCES' || // ADB available, but we aren't allowed to run it
107110 e . code === 'EPERM' || // Permissions error launching ADB
111+ e . code === 'EBADF' || // ADB launch failed do to ulimit, I think?
108112 e . code === 'ECONNREFUSED' || // Tried to start ADB, but still couldn't connect
109113 e . code === 'ENOTDIR' || // ADB path contains something that's not a directory
110114 e . signal === 'SIGKILL' || // In some envs 'adb start-server' is always killed (why?)
0 commit comments