-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Missing action
Function Returns 500 Instead of 405
#5507
Comments
@joshboley Can't reproduce on my side. |
I am also seeing this issue in 1.14.0 |
@machour Have done a bit of digging into this and it seems like what's happening is that the 405 error response is not be identified as a valid Perhaps related to this change from December #4782 remix/packages/remix-server-runtime/server.ts Lines 365 to 373 in a0341c9
|
@machour sorry for the late replay. I was able to reproduce this by using @jazanne thanks for digging into this and confirming! |
Any thoughts on whether or not this will be prioritized? It's a pretty disruptive issue for us since it skews the number of unexpected errors / 500s we see in monitoring. |
This is still reproducible on |
Here's a patch to fix the issue in Remix v1.15.0 diff --git a/node_modules/@remix-run/server-runtime/dist/responses.js b/node_modules/@remix-run/server-runtime/dist/responses.js
index d042d61..1e6d5c6 100644
--- a/node_modules/@remix-run/server-runtime/dist/responses.js
+++ b/node_modules/@remix-run/server-runtime/dist/responses.js
@@ -47,7 +47,7 @@ function isDeferredData(value) {
return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function";
}
function isResponse(value) {
- return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
+ return value instanceof router.ErrorResponse || (value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined");
}
const redirectStatusCodes = new Set([301, 302, 303, 307, 308]);
function isRedirectStatusCode(statusCode) {
diff --git a/node_modules/@remix-run/server-runtime/dist/server.js b/node_modules/@remix-run/server-runtime/dist/server.js
index fd10bc5..b924771 100644
--- a/node_modules/@remix-run/server-runtime/dist/server.js
+++ b/node_modules/@remix-run/server-runtime/dist/server.js
@@ -110,6 +110,9 @@ async function handleDataRequestRR(serverMode, staticHandler, routeId, request,
return response;
} catch (error) {
if (responses.isResponse(error)) {
+ if (error.headers === undefined) {
+ error.headers = new Headers()
+ }
error.headers.set("X-Remix-Catch", "yes");
return error;
}
@@ -251,6 +254,9 @@ async function handleResourceRequestRR(serverMode, staticHandler, routeId, reque
return response;
} catch (error) {
if (responses.isResponse(error)) {
+ if (error.headers === undefined) {
+ error.headers = new Headers()
+ }
// Note: Not functionally required but ensures that our response headers
// match identically to what Remix returns
error.headers.set("X-Remix-Catch", "yes"); |
This is fixed by #6320 and should be available in the next release (which should be 1.17.0) |
🤖 Hello there, We just published version Thanks! |
What version of Remix are you using?
1.13.0
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
Example Route:
Expected Behavior
During the non-GET request, POST in this example, a 405 status code should be returned, based on this discussion.
Actual Behavior
The returned status code is 500. Note however, that the Remix server outputs 405, but that is not the status code actually received by the caller.
Example curl:
But note the output in the terminal from the running Remix server:
The text was updated successfully, but these errors were encountered: