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
"outcome": "canceled"
"outcome": "canceled"
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
JustinNoel
JustinNoel17mo ago
I'd try to wrap your whole handler in a try/catch. Then, in the catch, console log whatever errr you may be getting.
rodrigo
rodrigo17mo ago
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 .
JustinNoel
JustinNoel17mo ago
Where do you see this? What's it from?
"outcome": "canceled"
rodrigo
rodrigo17mo ago
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
rodrigo
rodrigo17mo ago
JustinNoel
JustinNoel17mo ago
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.
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
rodrigo
rodrigo17mo ago
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?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
rodrigo
rodrigo17mo ago
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???) )
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
rodrigo
rodrigo17mo ago
You mean to place all functions within a context.waitUntil() in the Remix action?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
rodrigo
rodrigo17mo ago
I think it works with waitUntil. I need to test it it deeper, but it seems to work! Thanks!