@@ -17,6 +17,8 @@ export const EMULATOR_HOST_IPS = [
17
17
'10.0.3.2' , // Genymotion localhost ip
18
18
] ;
19
19
20
+ let reportedAdbConnError = false ;
21
+
20
22
export function createAdbClient ( ) {
21
23
const client = adb . createClient ( {
22
24
port : process . env [ 'ANDROID_ADB_SERVER_PORT' ]
@@ -43,13 +45,14 @@ export function createAdbClient() {
43
45
// We listen for errors and report them. This only happens if adbkit completely
44
46
// fails to handle or listen to a connection error. We'd rather report that than crash.
45
47
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 ) ;
49
55
}
50
-
51
- console . log ( 'ADB client error:' , e . message ?? e ) ;
52
- logError ( e ) ;
53
56
} ) ;
54
57
55
58
return client ;
@@ -105,6 +108,7 @@ export const getConnectedDevices = batchCalls(
105
108
e . code === 'ENOENT' || // No ADB available
106
109
e . code === 'EACCES' || // ADB available, but we aren't allowed to run it
107
110
e . code === 'EPERM' || // Permissions error launching ADB
111
+ e . code === 'EBADF' || // ADB launch failed do to ulimit, I think?
108
112
e . code === 'ECONNREFUSED' || // Tried to start ADB, but still couldn't connect
109
113
e . code === 'ENOTDIR' || // ADB path contains something that's not a directory
110
114
e . signal === 'SIGKILL' || // In some envs 'adb start-server' is always killed (why?)
0 commit comments