GCP Logs Error: "Response Error" When Header Status Code Differs from 200
As you have observed, your GCP Cloud Functions trigger an error message "Function execution took xxx ms. Finished with status: response error" when the header status code is not set to the default 200. This issue surfaced recently and did not occur previously.
To understand the root cause, let's examine the code provided:
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 }
By setting the status code to 201 (or any other non-200 value), you indicate a non-successful request. However, this triggers the response error in the logs.
Resolution
As of May 17, 2022, Google has resolved this internal issue, and Cloud Functions should now behave as expected. If you continue to encounter the error message, please contact Google Support for further assistance.
The above is the detailed content of Why Does My GCP Cloud Function Report a \'Response Error\' When the HTTP Status Code Isn\'t 200?. For more information, please follow other related articles on the PHP Chinese website!