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

UnhandledPromiseRejectionWarning: no such file or directory, uv_cwd #536

Open
chase-moskal opened this issue Jun 4, 2019 · 4 comments
Open

Comments

@chase-moskal
Copy link

hello friends, i've been enjoying serve while developing some websites

while working on a website, i encountered an error when attempting to load my website from "localhost:5000"

> nce-magazine@0.2.2 start /home/brim/Desktop/work/nce-magazine
> cd dist && serve


   ┌──────────────────────────────────────────────────┐
   │                                                  │
   │   Serving!                                       │
   │                                                  │
   │   - Local:            http://localhost:5000      │
   │   - On Your Network:  http://192.168.1.68:5000   │
   │                                                  │
   │   Copied local address to clipboard!             │
   │                                                  │
   └──────────────────────────────────────────────────┘

(node:13251) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, uv_cwd
    at module.exports (/home/brim/Desktop/work/nce-magazine/node_modules/serve-handler/src/index.js:523:22)
    at Server.http.createServer (/home/brim/Desktop/work/nce-magazine/node_modules/serve/bin/serve.js:180:10)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13251) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:13251) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
^C
INFO: Gracefully shutting down. Please wait...
(node:13251) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, uv_cwd
    at module.exports (/home/brim/Desktop/work/nce-magazine/node_modules/serve-handler/src/index.js:523:22)
    at Server.http.createServer (/home/brim/Desktop/work/nce-magazine/node_modules/serve/bin/serve.js:180:10)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13251) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
^C
WARNING: Force-closing all open sockets...
Terminated

the browser seemed to just hang

the problem seemed to go away after i corrected some goofy paths, maybe there's some kind of path i was passing that caused this error, i'm not sure, but i'm now moving onward with my work

i'll let you know if i run into the error again, sorry i am unable to provide a reproduction or investigate further at this time

godspeed! 👋

@chase-moskal
Copy link
Author

chase-moskal commented Jun 4, 2019

it keeps happening, and i think i know why

  • i'm serving my dist/ directory via cd dist && serve
  • however i'm also deleting that dist/ directory and rewriting it every time i run a build...
    the directory that serve is serving is actually disappearing
  • i updated my "clean" routine from rimraf dist to rimraf dist/*, and this fixed the issue for me

an enhancement for serve would be to improve the error handling here such that no promises are dropped

cheers 👋

@pablopunk
Copy link
Contributor

@chase-moskal another workaround is to serve dist/ instead of navigating to dist and then serve (you're doing that)

:)

@pablopunk
Copy link
Contributor

pablopunk commented Jun 27, 2019

I'm gonna think of a solution to this issue but I wouldn't just silence the error, I think serve should just show what's going on to the user and exit, because it's serving a folder that doesn't exist anymore. Even if you are kind of creating it again, it's not really the same folder.

Actually if you just cd into the folder with bash, you'll see the error <no current directory> in your prompt once you build again, because the new dist/ folder is not the same as it was. If you do echo $PWD it will throw:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
dirs: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

So I guess the correct way of doing it it's serve dist in your project folder.

@chase-moskal
Copy link
Author

chase-moskal commented Jun 27, 2019

@pablopunk

@chase-moskal another workaround is to serve dist/ instead of navigating to dist and then serve (you're doing that)

ah yes, that's a much better way! thanks!

I'm gonna think of a solution to this issue but I wouldn't just silence the error,

so long as the architecture is such that no promise errors get dropped or unhandled

it would be appropriate for serve to log this to stderr, but the most important thing is that serve's architecture should be made watertight so that no errors are slipping through the cracks at all — all errors should be caught if even they are unknown or unexpected

cheers!

👋 Chase

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

No branches or pull requests

2 participants