Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ibash
Copy link

@ibash ibash commented Jun 16, 2020

fs.copy was silently exiting when a socket was encountered in my
directory. This prevents silent failure so the user can deal with using
fs.copy appropriately.

@RyanZim RyanZim requested a review from manidlou June 16, 2020 13:24
Copy link
Collaborator

@RyanZim RyanZim left a comment

Choose a reason for hiding this comment

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

Initial concept looks OK; thought I'm not a real expert here; will get @manidlou's second opinion.

Should be mirrored for copySync, though:

else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)

@RyanZim
Copy link
Collaborator

RyanZim commented Jun 16, 2020

Is this technically semver-major, since we're turning a buggy silent exit into an error?

fs.copy was silently exiting when a socket was encountered in my
directory. This prevents silent failure so the user can deal with using
fs.copy appropriately.
@ibash
Copy link
Author

ibash commented Jun 16, 2020

Updated copySync

Is this technically semver-major, since we're turning a buggy silent exit into an error?

I think it could be argued both ways. On one hand semver is about having a public api. In this instance this code broke the conventional contract that callbacks are always called, so it's correcting undefined behavior.

On the other hand it really depends on what users of the library are expecting. I got here via stepping through electron-packager code until I found where execution stopped. electron-packager definitely wasn't expecting callbacks to not be called (there's actually a number of bug reports about it exiting halfway because of things like this).

The other major users are https://github.com/webpack-contrib/eslint-loader https://github.com/GoogleChrome/workbox and https://github.com/danethurber/webpack-manifest-plugin.

So maybe @ricardogobbosouza @jeffposnick and @DanielRuf?

@DanielRuf
Copy link
Contributor

I think you mentioned me by accident. I was only a normal contributor for a small CI related PR, nothing more: shellscape/webpack-manifest-plugin@b55ac5d

@DanielRuf
Copy link
Contributor

Besides this, turning a silent error (warning or notice in other frameworks and languages) to an actual (fatal) error is a breaking change as an error breaks the program flow.

@ibash
Copy link
Author

ibash commented Jun 16, 2020

Ah my bad, I just mentioned the last author on master :)

@ibash ibash requested a review from RyanZim June 17, 2020 03:17
Copy link
Collaborator

@RyanZim RyanZim left a comment

Choose a reason for hiding this comment

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

LGTM; but would like @manidlou to review before merge.

Copy link
Collaborator

@manidlou manidlou left a comment

Choose a reason for hiding this comment

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

This is good but I am wondering if that'd be better to throw a more descriptive error by checking all the remaining file types (socket and FIFO pipe) that fs.Stats object returns. I mean something like this:

else if (srcStat.isSocket()) return cb(new Error(`Cannot copy a socket file: ${src}`))
else if (srcStat.isFIFO()) return cb(new Error(`Cannot copy a FIFO pipe: ${src}`))
return cb(new Error(`Unknown file: ${src}`))

RyanZim added a commit that referenced this pull request Apr 1, 2021
@RyanZim RyanZim closed this in #880 Apr 2, 2021
RyanZim added a commit that referenced this pull request Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants