Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkdirsSync fails misleadingly if directory exists, but cannot be stat-ed. #625

Closed
igor-petruk opened this issue Sep 19, 2018 · 6 comments
Closed

Comments

@igor-petruk
Copy link

igor-petruk commented Sep 19, 2018

https://github.com/jprichardson/node-fs-extra/blob/master/lib/mkdirs/mkdirs-sync.js#L43

I have a docker container which mounts the directory as a host path bind mount. The operation fails with a misleading error.

/usr/local/lib/node_modules/app/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:45
        throw err0
Error: EEXIST: file already exists, mkdir

There is probably something wrong with the permissions, but the directory fails to be stat-ed. I can investigate deeper to provide what is the exact exception err1 is swallowed by

      try {
        stat = xfs.statSync(p)
      } catch (err1) {
        throw err0
      }

but we should make a more fine-grained check here and depending on what is the error, throw either err1 or err0.

@RyanZim
Copy link
Collaborator

RyanZim commented Sep 19, 2018

Yeah, this is weird, I wonder what error is getting thrown here. Also, what platform is this?

@igor-petruk
Copy link
Author

igor-petruk commented Sep 19, 2018 via email

@RyanZim
Copy link
Collaborator

RyanZim commented Sep 19, 2018

The purpose of the stat call is so that we can check if it's actually a directory. If it's a file with the same name, throwing EEXISTS is appropriate.

@Manvel
Copy link

Manvel commented Oct 14, 2018

moveSync seems to also fail with similar Error: EEXIST: file already exists, link ... error.

@RyanZim
Copy link
Collaborator

RyanZim commented Jan 30, 2020

#619 may fix this.

@RyanZim
Copy link
Collaborator

RyanZim commented Jul 29, 2020

If this is still reproducible on Node 10.12+ and latest fs-extra, please comment here, otherwise, will close and assume fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants