Back out "[flipper] Explicitly start adb server"

Summary:
Original commit changeset: b1eae542aaa6

 This D13487864 has broken `adb start-server` command for the production builds, thus this diff backs out the changes done by that diff.

Reviewed By: danielbuechele

Differential Revision: D13532003

fbshipit-source-id: 1d169dcdab11a52f075187803219915f444952d6
This commit is contained in:
Pritesh Nandgaonkar
2018-12-21 07:01:56 -08:00
committed by Facebook Github Bot
parent 9d4bb45dbc
commit 470c770e97
3 changed files with 43 additions and 14 deletions

View File

@@ -71,6 +71,7 @@
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"openssl-wrapper": "^0.3.4", "openssl-wrapper": "^0.3.4",
"promise-retry": "^1.1.1",
"prop-types": "^15.6.0", "prop-types": "^15.6.0",
"react": "16", "react": "16",
"react-color": "^2.11.7", "react-color": "^2.11.7",

View File

@@ -7,7 +7,7 @@
import AndroidDevice from '../devices/AndroidDevice'; import AndroidDevice from '../devices/AndroidDevice';
import child_process from 'child_process'; import child_process from 'child_process';
import {promisify} from 'util'; import promiseRetry from 'promise-retry';
import type {Store} from '../reducers/index.js'; import type {Store} from '../reducers/index.js';
import type BaseDevice from '../devices/BaseDevice'; import type BaseDevice from '../devices/BaseDevice';
import type Logger from '../fb-stubs/Logger.js'; import type Logger from '../fb-stubs/Logger.js';
@@ -55,21 +55,31 @@ function getRunningEmulatorName(id: string): Promise<?string> {
} }
export default (store: Store, logger: Logger) => { export default (store: Store, logger: Logger) => {
// Adbkit will attempt to start the adb server if it's not already running, // Using this client before adb server is started up will cause failures.
// however, it sometimes fails with ENOENT errors. So instead, we start it // this gets around this by waiting for listDevices first, which ensures
// manually before requesting a client. // the server is up and running before allowing any other operations.
function createClient() { function createClient() {
return promisify(child_process.exec)('adb start-server') const unsafeClient = adb.createClient();
.then(result => { return promiseRetry(
if (result.error) { (retry, number) => {
throw new Error( return unsafeClient
`Failed to start adb server: ${result.stderr.toString()}`, .listDevices()
); .then(() => {
} return unsafeClient;
}) })
.then(adb.createClient); .catch(e => {
console.warn(`Failed to start adb client. Retrying. ${e.message}`);
retry(e);
});
},
{
minTimeout: 200,
retries: 5,
},
);
} }
const clientPromise = createClient();
const watchAndroidDevices = () => { const watchAndroidDevices = () => {
// get emulators // get emulators
@@ -88,7 +98,7 @@ export default (store: Store, logger: Logger) => {
}, },
); );
createClient() clientPromise
.then(client => { .then(client => {
client client
.trackDevices() .trackDevices()

View File

@@ -2287,6 +2287,11 @@ env-paths@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-1.0.0.tgz#4168133b42bb05c38a35b1ae4397c8298ab369e0" resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-1.0.0.tgz#4168133b42bb05c38a35b1ae4397c8298ab369e0"
err-code@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/err-code/-/err-code-1.1.2.tgz#06e0116d3028f6aef4806849eb0ea6a748ae6960"
integrity sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA=
error-ex@^1.2.0: error-ex@^1.2.0:
version "1.3.1" version "1.3.1"
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
@@ -5158,6 +5163,14 @@ progress@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
promise-retry@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/promise-retry/-/promise-retry-1.1.1.tgz#6739e968e3051da20ce6497fb2b50f6911df3d6d"
integrity sha1-ZznpaOMFHaIM5kl/srUPaRHfPW0=
dependencies:
err-code "^1.0.0"
retry "^0.10.0"
promise@^7.1.1: promise@^7.1.1:
version "7.3.1" version "7.3.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
@@ -5669,6 +5682,11 @@ ret@~0.1.10:
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==
retry@^0.10.0:
version "0.10.1"
resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4"
integrity sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q=
rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1: rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1:
version "2.6.2" version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"