R: fix 500 error bug

This commit is contained in:
aki-0421 2023-04-20 21:29:18 +09:00
parent 1e152e5743
commit a867a2dcbf
No known key found for this signature in database
GPG Key ID: 64A8CF6D437D166A

View File

@ -28,5 +28,12 @@ func WaitUntil(ctx context.Context, task func()) {
// see: https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#passthroughonexception
func PassThroughOnException(ctx context.Context) {
exCtx := cfruntimecontext.GetExecutionContext(ctx)
jsutil.AwaitPromise(jsutil.NewPromise(js.FuncOf(func(this js.Value, pArgs []js.Value) any {
resolve := pArgs[0]
go func() {
exCtx.Call("passThroughOnException")
resolve.Invoke(js.Undefined())
}()
return js.Undefined()
})))
}