GCP logs show function "Function execution took xxx ms. Finished with status: response error" whenever my header status code is not 200

huangapple go评论76阅读模式
英文:

GCP logs show function "Function execution took xxx ms. Finished with status: response error" whenever my header status code is not 200

问题

如标题所述,每当我将响应头设置为除默认值(200)以外的任何状态代码时,我的日志中都会出现响应错误。几周前还没有这种情况,所以我不确定为什么现在会发生。另一个线程:https://stackoverflow.com/questions/68865573/firebase-cloud-function-finished-with-status-response-error
说我的函数的HTTP响应请求超过了10MB。然而,我决定只部署一个函数(getTest),它只是:

package foo

import (
	"net/http"
)

func GetTest(w http.ResponseWriter, r *http.Request) {
	// 状态码测试
	w.WriteHeader(201) // 使用状态码201进行测试
	return
}

但我仍然收到一个“响应错误”。在上面的测试代码中,将任何状态码(201、400、404、500等)替换为200将导致成功的GCP日志记录状态码200。

此外,如果前一个调用以响应错误结束,GCP有时会自动再次调用该函数,并返回状态码200,如图1所示。我之所以说有时是因为我无法始终重现这个问题。我相信在这个重新调用期间,我的代码实际上没有执行任何操作,只是返回了200。

有人知道问题是什么吗?

编辑:我还想指出,我只在Cloud Function日志中看到这个“响应错误”。在我的API网关日志中,我看到函数结束时的正确状态码。

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: https://stackoverflow.com/questions/68865573/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.

GCP logs show function "Function execution took xxx ms. Finished with status: response error" whenever my header status code is not 200

答案1

得分: 2

更新:

GCP Functions在日志中收到一个响应错误,错误信息为Function execution took xxx ms. Finished with status: response error,当头部状态码未设置为200时。这是Google的一个内部问题,在2022年5月17日的发布中得到修复。现在您可以期望Cloud Functions按预期工作。如果您有任何进一步的疑问,或者问题仍然存在,请联系Google支持,网址为issuetracker.google.com/issues/…,或者提出一个支持案例。

英文:

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.

huangapple
  • 本文由 发表于 2022年4月14日 17:45:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/71869587.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定