koajs / koa-body

koa body parser middleware
MIT License
950 stars 130 forks source link

Error forces Koa instance to die and need a restart #38

Closed pjotrsavitski closed 7 years ago

pjotrsavitski commented 8 years ago

Context: koaBody is configured with file uploads and custom uploadsDir. If the directory does not exist, an error is thrown that forces the process to require a restart.

Error: ENOENT: no such file or directory, open

Current local setup uses pm2 to manage process that restarts it, although it would be nice if that kind of things would not force the Koa server process to halt.

Seems like this is being propagated from Formidable.

FlorianWendelborn commented 8 years ago

I'm not sure if koa-body should fix this or not. A workaround would definitely be to use mkdir -p to assure that you have all required directories.

pjotrsavitski commented 8 years ago

That seems like a meaningful approach and could even be handled in an automated manner. The issue is more with error forcing the Koa app server to crash. There might be some other cases that could potentially throw an error.

If Koa app would restart on those for no good reason, then it seems to be an issue.

I might be wrong, but the way things generally are is that errors are just caught and dealt with, not crash the process and force a restart.