Code Monkey home page Code Monkey logo

Comments (7)

sorccu avatar sorccu commented on July 23, 2024

I agree that the documentation is wrong, we'll need to fix that. But I don't see how you would get either a buffer or a stream randomly... I just tried the example code as-is and it worked fine. Can you share some more details about your investigation?

from adbkit.

op1ekun avatar op1ekun commented on July 23, 2024

Sure, I'm glad to help.

I call this code as a part of my device resilience subsystem:

client.shell(serial, 'ifconfig wlan0')
    .then(adb.util.readAll)
    .then(function commandResult(result) {
        return result.toString()
    });

...and, as you've already suggested, it produces the error in a random way :(
I have no idea, maybe it's the command, maybe it's the device the thing is I randomly get a Buffer instead of a Stream.

I totally forgot to add my env data:
Version of adbkit: 2.3.1
Node: 0.10.40
System: Windows Server 2012 R2
Device: Nexus 7, Android 5.1.1

Other than that, GREAT JOB, this module saves lives ;)

from adbkit.

sorccu avatar sorccu commented on July 23, 2024

Might be worth trying with Node 0.12 or 4.x. We haven't tested 0.10 in a long time and there were some stream-related changes in 0.12 that I remember having to fix (although it could have been just that our code was bad). Also we've never tested anything on Windows... :)

Are you sure it really returns a buffer and not something else? Could you do .then(function(really) { console.log('really?', really, typeof really) }) instead of readAll?

from adbkit.

sorccu avatar sorccu commented on July 23, 2024

Also, https://github.com/petkaantonov/bluebird/blob/master/API.md#promiselongstacktraces---void may or may not help a little in providing a more useful stack trace.

from adbkit.

op1ekun avatar op1ekun commented on July 23, 2024

I will update my node.js to 0.12.7, and I will check the Buffer hipothesis :)
Thanks!

from adbkit.

op1ekun avatar op1ekun commented on July 23, 2024

So after one day of scrutinizing the code, and running test on real hardware there and back again, it seems that there was an issue with the old version of node.js.
The 0.12.7 version appears to be as stable as a solid rock.
Thanks for all the help :)

from adbkit.

joshuapinter avatar joshuapinter commented on July 23, 2024

It took me awhile to figure out how to use readAll() with Promises so I'm positing it here to help others:

const stream = await adbClient.shell( config.udid, "ime list -s" )
const result = await adb.util.readAll( stream );
console.log( result.toString() ); // => com.sec.android.inputmethod/.SamsungKeypad

from adbkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.