tidev / node-ios-device

Queries connected iOS devices and installs apps
Other
122 stars 37 forks source link

.trackDevices fails about one tenth of the time. #14

Closed rosesandhello closed 8 years ago

rosesandhello commented 8 years ago

Devices being added or removed are not noticed roughly 1/10 of the time. I'm not sure what other information to provide along with this.

I am using an ES7 async function as the callback for trackDevices, if that's at all relevant.

cb1kenobi commented 8 years ago

Can you give me some more information? What version of OS X? How many devices are you connecting? Do you get a crash or is just not reporting the newly connected device?

Since ES7 async functions are just sugar around promises, you should know that promises are fired once, yet trackDevices() is called continuously. You should stop tracking devices as soon as the device state changes. trackDevices() returns a function that stops the tracking. You just need to call it before resolving the promise.

rosesandhello commented 8 years ago

OSX 10.11.4, four iOS devices (5s, 6, 6+, 6s+). Having provided a normal function as a callback, the problem persists.

cb1kenobi commented 8 years ago

What version of Node.js?

rosesandhello commented 8 years ago

5.4.1

cb1kenobi commented 8 years ago

Hmm, I'm trying to reproduce the problem, but I'm not quite able to get the problem to occur.

Have you tried restarting your computer? I know that sounds silly, but being that node-ios-device is using the same library that iTunes uses, I suppose it's possible for something on the library side to mess up and a reboot should clear it up.

cb1kenobi commented 8 years ago

OK, I just took a look at node-ios-device and did a bunch of changes (#15).

I carefully reviewed and re-tested the code and I was able to reproduce a state where devices wouldn't show up despite being plugged in. This was due to a race condition and I managed to fix it.

I've published version 0.9.0. Please give that a try. I'll close this ticket, but if the problem persists, please reopen the ticket. Likewise, if a new problem occurs, please let me know and I'll take a look. Thanks!

rosesandhello commented 8 years ago

Nailed it. Thanks so much!