'GCP logs show function "Function execution took xxx ms. Finished with status: response error" whenever my header status code is not 200
As stated in the title, whenever I set my response header to be any status code besides the default (200), I receive a response error in my logs. This did not happen a few weeks ago so I am not sure why it is happening now. Another thread: Firebase Cloud Function finished with status: 'response error' said that the HTTP request of response of my function is higher than 10MB. However, I decided to just deploy a function (getTest) that is just
package foo
import (
"net/http"
)
func GetTest(w http.ResponseWriter, r *http.Request) {
// Status Code Test
w.WriteHeader(201) // Testing with status code 201
return
}
and I am still returned a 'response error'. Replacing any status code (201,400,404,500,etc.) for 200 in the above test code would result in a successful GCP log of status code 200.
Furthermore, GCP would sometimes automatically invoke the function again with a status 200 if the previous invocation ended in a response error as shown in photo #1. I say sometimes because I cannot consistently exhibit the issue. It is to my belief that during this re-invocation nothing in my code is actually executed and it just returns a 200.
Does anyone know the issue?
Edit: I also want to point out I only see this "response error" on Cloud Function Logs. On my API gateway logs, I see the correct status code the function ended on.
Solution 1:[1]
UPDATE :
GCP Functions were receiving a response error in the logs Function execution took xxx ms. Finished with status: response error
for quite some time whenever the header status code was not set to 200. This was an internal issue with Google which got fixed with the roll out on 17th May 2022. You can expect Cloud functions to work in the expected manner now. If you have any further queries or if it is still an issue with you, you can contact Google Support at issuetracker.google.com/issues/… or raise a support case.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Priyashree Bhadra |