Closed2

Supabase Webhooks→Cloudflare Workersでoutcomeがcanceledになって困った

9 shock9 shock

問題

クライアント→Supabaseのデータベース変更→Cloudflare Workers→Cloudflare Imagesで画像削除
という処理を行いたかったが、何回やってもCloudflare Workersでoutcomeがcanceledになってしまっていた。

調べる

Cloudflare Workers outcome canceledでググると

As long as the client that sent the request remains connected, the Worker can continue processing, making subrequests, and setting timeouts on behalf of that request. When the client disconnects, all tasks associated with that client request are canceled

https://developers.cloudflare.com/workers/platform/limits/
とある。Cloudflare WorkersのfreeのCPUの実行時間は10msらしいがこれはawaitしている時間は含めないので大丈夫らしい。これを見るとclientがdisconnectするとだめらしい。
→CloudflareのほうはタイムアウトしないけどWebhooksの方がタイムアウトした?
(Cloudflare Workersのtimestampを見てみるとおよそ4.45秒かかってた。)
→Webhooksのデフォルトでのtimeoutを見てみると1000msで最大5000msまで行けるので
5000msにすると解決した。

ただこれだとギリギリな気がするので方法を変えた方がいいかもしれない。
秒数がかかっているのはCloudflare Imagesにリクエストを送っているときで2秒ほどかかっている。
https://developers.cloudflare.com/workers/runtime-apis/handlers/tail/

9 shock9 shock

Cloudflare Imagesにリクエストを二回送っているから2×2秒でぎりぎりになってしまっているから、
分けてやった方がいいかもしれない。
根本的にやり方がよくない?

このスクラップは2023/11/10にクローズされました