adbkit icon indicating copy to clipboard operation
adbkit copied to clipboard

Process fails to quit due to issue in opening and ending logcat

Open eliperelman opened this issue 11 years ago • 4 comments

Switching over from adbkit-logcat to adbkit, and my Node.js process fails to quit because something in logcat must still be in the stack. Previously this wasn't an issue in adbkit-logcat as it's recommended you kill the stream process upon exit, but I don't see a way to access the logcat process using the mechanisms provided by adbkit. The stream end method does not let the process end. Using the following reduced test case:

var adb = require('adbkit');
var client = adb.createClient();

client.listDevices()
  .then(function(devices) {
    var deviceId = devices[0].id;

    client.openLogcat(deviceId)
      .then(function(logcat) {
        setTimeout(function() {
          console.log('ending logcat');
          logcat.end();
        }, 5000);
      });
  });

eliperelman avatar Jan 14 '15 01:01 eliperelman

Running with DEBUG=* shows nothing in the console when .ending the logcat:

adb:command Send '000Chost:devices' +0ms
adb:command Send '0017host:transport:94fdce73' +3ms
adb:command Send '001Fshell:logcat -B *:I 2>/dev/null' +1ms

eliperelman avatar Jan 14 '15 01:01 eliperelman

Hi,

Thanks for letting me know. I will check this today.

On Wednesday, January 14, 2015, Eli Perelman [email protected] wrote:

Running with DEBUG=* shows nothing in the console when .ending the logcat:

adb:command Send '000Chost:devices' +0ms adb:command Send '0017host:transport:94fdce73' +3ms adb:command Send '001Fshell:logcat -B *:I 2>/dev/null' +1ms

— Reply to this email directly or view it on GitHub https://github.com/CyberAgent/adbkit/issues/22#issuecomment-69853002.

sorccu avatar Jan 14 '15 01:01 sorccu

On OS X, using nettop:

adb.724                                                                                           84 B
    tcp4 127.0.0.1:5037<->localhost:58777                            lo0     Established          62 B
    tcp4 127.0.0.1:56672<->*:*                                       lo0          Listen
    tcp4 127.0.0.1:56522<->*:*                                       lo0          Listen
    tcp4 127.0.0.1:56519<->*:*                                       lo0          Listen
    tcp4 127.0.0.1:5037<->localhost:49616                            lo0     Established          22 B
    tcp4 127.0.0.1:5037<->*:*                                        lo0          Listen

Looks like after killing the Node.js process, the Net connections are still present. Running adb kill-server has cleared them up.

eliperelman avatar Jan 14 '15 01:01 eliperelman

This seems to be due to a misunderstanding on my part. Calling .end() on a pipe target doesn't end the source stream. Will patch soonish.

sorccu avatar Jan 14 '15 14:01 sorccu