Add timeouts everywhere. Should help if the ADB socket gets stuck like it sometimes does.

This commit is contained in:
Simo Kinnunen
2014-04-02 11:58:53 +09:00
parent 64d4782436
commit 0ce65687c5
10 changed files with 51 additions and 5 deletions

View File

@@ -36,6 +36,7 @@ module.exports = syrup.serial()
function removeResource(res) {
return adb.shell(options.serial, ['rm', res.dest])
.timeout(10000)
.then(function(out) {
return streamutil.readAll(out)
})
@@ -44,6 +45,7 @@ module.exports = syrup.serial()
function installResource(res) {
return adb.push(options.serial, res.src, res.dest, res.mode)
.timeout(10000)
.then(function(transfer) {
return new Promise(function(resolve, reject) {
transfer.on('error', reject)
@@ -55,9 +57,11 @@ module.exports = syrup.serial()
function ensureNotBusy(res) {
return adb.shell(options.serial, [res.dest, '--help'])
.timeout(10000)
.then(function(out) {
// Can be "Text is busy", "text busy"
return streamutil.findLine(out, (/busy/i))
.timeout(10000)
.then(function() {
log.info('Binary is busy, will retry')
return Promise.delay(1000)
@@ -80,11 +84,12 @@ module.exports = syrup.serial()
function stop() {
return devutil.killProcsByComm(
adb
, options.serial
, resources.bin.comm
, resources.bin.dest
)
adb
, options.serial
, resources.bin.comm
, resources.bin.dest
)
.timeout(15000)
}
return stop()