balena-io-modules / drivelist

List all connected drives in your computer, in all major operating systems
Apache License 2.0
241 stars 90 forks source link

Error: Couldn't initialize the scanner: An unknown error occurred #198

Closed barchard closed 7 years ago

barchard commented 7 years ago

Hi, I have started receiving this error on Win10 (Creators Update) in Node + Electron. I am getting this error when calling .list() method in order to list devices. Strangely, this was previously working. Obviously, the error is vague so I'm not sure how to proceed. Any advice is appreciated. Thanks

barchard commented 7 years ago

I should add, reverting to v5.0.22 fixes the issue. I will find out which version this first appears in.

barchard commented 7 years ago

NPM wouldn't allow me to install v5.0.23 or v5.0.24. It said the only versions available are v5.0.27, v5.0.26, v5.0.25, and v5.0.22. The error first appears in v5.0.25.

rswamy commented 7 years ago

I am setting up a new instance of my nodejs app (today) and was receiving some strange errors with the drivelist module when trying to run it. Googling led me to this issue somehow. My app fails with v5.0.27 so I reverted to v5.0.25 which I knew worked from a previous instance. Can't contribute more than this anecdote, I will need to look at what changed between these versions...

jviotti commented 7 years ago

Hi @barchard @rswamy ,

NPM wouldn't allow me to install v5.0.23 or v5.0.24. It said the only versions available are v5.0.27, v5.0.26, v5.0.25, and v5.0.22. The error first appears in v5.0.25.

Sorry about that. We're adopting an company wide technology to handle automated versioning and deployment, and things didn't go very smoothly on certain versions, which have not been published to npm.


The new drivelist version contains a very large change, where we re-wrote the Windows drive scanning routines in C++, to workaround a bug coming from WMI itself, where the reported drive sizes were not accurate for some drives.

Can you guys try to re-run drivelist with the DRIVELIST_DEBUG variable set? For example:

git clone https://github.com/resin-io-modules/drivelist
cd drivelist
npm install
set DRIVELIST_DEBUG=1
node example

That should provide debugging information so we can pin-point the issue.

barchard commented 7 years ago

When I do this, all I see in the command prompt is:

[drivelist] Initializing scanner
[drivelist] Initializing COM
[drivelist] Initializing COM security levels

Nothing else is printed.

jviotti commented 7 years ago

Thanks a lot @barchard. Can you try the debug-com branch? I added even more debugging information for that particular part of the code.

barchard commented 7 years ago

i tried building the branch then re-building it for electron. re-building the module for electron, however, fails. do you have instructions for getting it built and installed? thanks

jviotti commented 7 years ago

What error message do you get? I'm on Windows 10 with Node.js 6.1.0 and it works fine here.

Try the following:

git clone https://github.com/resin-io-modules/drivelist
cd drivelist
git checkout debug-com
npm install
set DRIVELIST_DEBUG=1
node example
rswamy commented 7 years ago

My (probably unrelated) issue was fixed when I used nodejs 6.4.0 because apparently between v5.0.25 and v5.0.27 you used arrow notations and they aren't supported in 5.12.0 (what I was using before). Oops!

TanninOne commented 7 years ago

I seem to get the same error

@jviotti following your instructions I get this output:

[drivelist] Initializing scanner [drivelist] Initializing COM [drivelist] Initializing COM security levels [drivelist] Creating connection instance [drivelist] Connecting to server [drivelist] Setting proxy security levels Interpreting error: 0x0 [drivelist] Getting list of drives from WMI [drivelist] Getting id [drivelist] Processing \.\PHYSICALDRIVE0 [drivelist] Getting caption [drivelist] Getting size [drivelist] Opening handle on \.\PHYSICALDRIVE0 [drivelist] Getting drive geometry [drivelist] Getting media type [drivelist] Getting system volume drive letter [drivelist] Getting available volumes [drivelist] Getting volume type [drivelist] Checking if volume has filesystem [drivelist] Getting device number [drivelist] Checking if disk is writable [drivelist] Getting volume type [drivelist] Ignoring, drive type not removable nor local [drivelist] Getting volume type [drivelist] Checking if volume has filesystem [drivelist] Getting device number Interpreting error: 0x80004005 Error: Couldn't scan the drives: An unknown error occurred at Error (native)

TanninOne commented 7 years ago

Ok, investigated a bit further, it appears to be tripping over a mounted virtual device. I have a "boxcryptor classic" drive mounted on Z:. If I unmount that, the example runs fine.

DuskDweller commented 7 years ago

I can confirm what TanninOne reported.

barchard commented 7 years ago

Running the latest debug branch with the instructions provided worked for me. Thanks.

jviotti commented 7 years ago

Awesome, thanks a lot for the help here. I'll send a PR fixing the virtual device issue and release a new version very soon!

jviotti commented 7 years ago

I fixed the virtual drive case in https://github.com/resin-io-modules/drivelist/pull/200. @barchard the original problem you reported seems to be another one, which fails when COM is being initialized. Could it be that something changes in your machine, accidentally fixing the error by the time you tested the debug branch?

lurch commented 7 years ago

It seems as though all the various reports of this bug are from people running Windows 10. Do we know if this is because the bug (or bugs) are specific to Windows 10, or is it just because most people happen to be running Windows 10 now?

barchard commented 7 years ago

I am running the creators update of Windows 10. Nothing I am aware of changed on the system with regards to drives. Only thing I've possibly changed is:

  1. Installed a USB Bluetooth dongle
  2. Rebooted

Maybe rebooting fixed it.

Sent from my iPhone

On Jul 31, 2017, at 8:46 AM, Andrew Scheller notifications@github.com wrote:

It seems as though all the various reports of this bug are from people running Windows 10. Do we know if this is because the bug (or bugs) are specific to Windows 10, or is it just because most people happen to be running Windows 10 now?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

lurch commented 7 years ago

Maybe rebooting fixed it.

Wouldn't be the first time that fixed a random Windows error... :rofl:

jviotti commented 7 years ago

@barchard We eventually got to the bottom of it. The issue happens when there are multiple drivelist scans happen in parallel on the same process. COM is initialized globally for the current process, so when multiple scans happen at the same time, they both try to initialize COM at the same time, which eventually fails.

barchard commented 7 years ago

Nice! Good catch 👍

Sent from my iPhone

On Jul 31, 2017, at 12:29 PM, Juan Cruz Viotti notifications@github.com wrote:

@barchard We eventually got to the bottom of it. The issue happens when there are multiple drivelist scans happen in parallel on the same process. COM is initialized globally for the current process, so when multiple scans happen at the same time, they both try to initialize COM at the same time, which eventually fails.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

mubed commented 7 years ago

I still have this problem in Version 1.1.2 (Win7): 2017-08-29 09_07_32-error

barchard commented 7 years ago

@mubed all of the discussions here have been in regards to version 5.0.22 and later. maybe update to the latest version? 1.1.2 sounds really old.

mubed commented 7 years ago

Where can I get a newer version, when 1.1.2 is what you see on "etcher.io"?! 2017-08-29 11_36_49-etcher - internet explorer - __remote - __remote

lurch commented 7 years ago

@mubed v1.1.2 is the latest version of Etcher. However one of the sub-components used within Etcher is drivelist (currently at v5.1.8), which is what this particular GH repo is about ;-)