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
Koajs converts thrown errors to status code 500 #1451
Comments
We can close this issue now. Fixed in #1460 PR. |
@vijaykrishnavanshi please add a test so this doesn't break in the future. I would have contributed with a PR but I didn't have time to set up the testing environment and didn't feel that only contributing the code was a complete solution. |
Already added those in the PR 👍 |
Thanks @vijaykrishnavanshi now I found it! |
If you use the AWS S3 Node.js client to create a proxy, it throws an error with status code 304 when an object hasn't been modified. This propagates to the Koa.js error handling code. Because Node.js sets the http status code of the error on the prop
err.statusCode
https://github.com/nodejs/node/blob/066bdec64352278ed324a1bb680f5422e00a3aa5/lib/_http_outgoing.js#L410
and Koa.js expects
err.status
, Koa.js will return a 500 instead of the actual status code set on the error object by Node.js.koa/lib/context.js
Line 150 in eda2760
I suggest adding the line
or changing to
so the developer doesn't have to set it manually, which is non-trivial to figure out and adds unnecessary code complexity in situations where node already has set a status code.
The text was updated successfully, but these errors were encountered: