how to debug a function
I'm creating a webhook in Supabase to update a CF Worker KV.
The point is that for every post request I can get the payload data but I cannot get any more info apart that post request is cancelled
I mean, I create
conselo.log
but this info doesn't show up in the request Real-time Logs.
How can I get debug info in the log?14 Replies
I'd try to wrap your whole handler in a try/catch. Then, in the catch, console log whatever errr you may be getting.
I have several try/catch but I don't get any error.
I've set some console.log and I have some info that look ok ...
But the point is requests are cancelled and the only info is
"outcome": "canceled",
. No idea how to get more info....
I've also set up the the Wokers to Unbound .Where do you see this? What's it from?
"outcome": "canceled"
In the Real-time Logs. It's clear it's due to an error in my code, but I cannot find a way to get more debug info than this 'canceled' (and I've set up try/catch everywhere in my code
I use some middleware to collect logs and send them to an external service when a request completes. It took me a while to get that working well.
A "simple" troublshooting technique you can use is to litter some KV writes throughout your code. If it gets to KV write #1, #2, and #3, you know that code is good. But if KV write #4 doesn't exist, you know the problem is between 3 and 4.
"canceled" usually means the client went away, IIRC
The client is a Supabase webhook that reaches a Remix action. Might the "cancelled" be due to the webhook goes away to soon? Could I use a header in the webhook to avoid this?
If you hit the Remix action directly with curl or whatever, what happens?
I've replicated the webhook post request in Postman with the same payload and it works! But it lasts 1300ms ... the webhook might be dropping the connection because it lasts too much? (it a Supabase webhook, working on AWS (Lambdas???) )
Perhaps. I’m not super familiar with how Supabase webhooks work. Might be worth moving the work into
waitUntil()
(or even using Queues if it’s going to get any more chunky) so you can return a response faster?You mean to place all functions within a
context.waitUntil()
in the Remix action
?Just the bulk of the work that you’re doing, yeah
I think it works with
waitUntil
. I need to test it it deeper, but it seems to work! Thanks!