Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Improve error handling on premature device disconnect #86

Closed
wants to merge 2 commits into from

Conversation

jhermsmeier
Copy link
Contributor

@jhermsmeier jhermsmeier commented Feb 23, 2017

Connects to:

Changes:

  • Disabled the no-bitwise eslint rule, as bitmasks couldn't be used otherwise
  • Added an access check before attempting to run diskpart

To do:

  • Add and document common error codes for these errors (ENXIO, ENOENT, EIO, ...)
  • Manually test this for proper behavior on Windows

@jhermsmeier jhermsmeier changed the title Premature disconnect Improve error handling on premature device disconnect Feb 23, 2017
@jviotti
Copy link
Contributor

jviotti commented Feb 23, 2017

I think I'm missing something, but this only addresses Windows, right?


// Test whether the device is accessible,
// and if not – throw – rejecting the promise
fs.accessSync(device, fs.constants.R_OK | fs.constants.W_OK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we make this async?

// Test whether the device is accessible,
// and if not – throw – rejecting the promise
fs.accessSync(device, fs.constants.R_OK | fs.constants.W_OK);

return retry(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that in the case of balena-io/etcher#1127, we have to check the drive exists inside the retry block, otherwise we catch an initial inconsistency, but if the drive gets removed in between two tries, the error still appears.

@jhermsmeier
Copy link
Contributor Author

I think I'm missing something, but this only addresses Windows, right?

No no, you're not missing anything, I just whipped this branch up so I can start testing it on Windows, because I wrote it on a different machine – hence the work-in-progress tag ;)

@jviotti
Copy link
Contributor

jviotti commented Feb 23, 2017

Ah, I see :) Cool, let me know once this reaches a reviewable state :)

@lurch
Copy link
Contributor

lurch commented Apr 20, 2017

What's the status of this PR now? Has it been partially superseded by @jviotti 's other recent changes?

@jhermsmeier jhermsmeier deleted the premature-disconnect branch November 19, 2017 10:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants