-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
koa shouldn't special-case ENOENT errors #1420
Comments
So, what exactly are you getting :) |
I think the semantics are pretty spot on. ENOENT is thrown when something (usually a file or a directory) isn't found, i.e. 404.
I don't get it, isn't 404 a perfect match for this? Requested resource not found. |
404 means "page not found", it doesn't mean "we got some error about a file not found". Koa doesn't know the context. Especially in this case it's a configuration error (some configuration file isn't found). Probably the google library should throw a better error, but still. |
I'm ok to remove the 'ENOENT' case, but it would be a breaking change. |
@julienw I guess it's a matter of subjective interpretation, but I guess my way of thinking is perhaps too "HTTP-minded". Either way, I think special casing should either be configurable or removed. But as dead-horse pointed out, it's a breaking change so at the very least, lets reference #1114 for future evaluation. |
Yeah this is a breaking change, I totally agree with that. I believe this was done initially to accommodate use cases like: ctx.body = fs.createReadStream(filePath); So I think we need a replacement for this. Maybe a middleware that would be part of koa (or another package) that would be then easy to add for somebody who wants this functionality? |
👍 this should be done downstream |
Has any decision been taken on this? |
I was hit by that as well. My perfectly legitimate API handler started to return 404 for no apparent reason. What happened was, deep inside, a third party library ( I don't see the problem with introducing a breaking change... May be it's time to fully use semver and don't be afraid of major version bumps? Many of us have done that and survived. 😆 |
I noticed that koa special-cases ENOENT errors:
koa/lib/context.js
Lines 146 to 147 in ed84ee5
I think this is a mistake: ENOENT errors could happen for a lot of reasons (this happens with google's storage library when the key file isn't found, for example) that shouldn't get a 404 status.
And BTW it's not even documented.
The text was updated successfully, but these errors were encountered: