Exceptions not being logged

Hi, I have a Remix app successfully deployed to Cloudflare Pages without issue. The app is running, working, no problem. However, if I throw an exception for any reason, and don't handle it, I get a server error. That's expected. What is not expected is that the logs in Cloudflare is empty. That is, if I do a try/catch and console.error my exception, that shows up fine (and the app runs successfully). But if I let the exception bubbles up, there's a server error, and the log entry is empty. The "exceptions" array in the logs on the Dashboard is an empty array, and exceptions don't show up when tailing the log through wrangler. Is there something special to do for exceptions to be properly handled? I tried throwing the exceptions in a vanilla handler to rule out Remix and I still get the same behavior.
1 Reply
Shados
Shados2mo ago
Ok, searching through this discord and doing more tests, it looks like I had some misunderstanding of how this works. Remix was handling the exception (I thought i was throwing it outside of the Remix context, I was wrong), and returning a 500 which is not an "exception" in Cloudflare. If I use the Remix global server error handler in entry.server.tsx and manually logs an exception there, it shows up (as a log). There's no real way to log an actual exception since Remix handles all of them. One caveat I haven't found a good solution for, is if there's an exception from the getLoadContext callback. That one doesn't get handled by the server handler, but still ends in a 500. So it seems you REALLY want a try/catch around your getLoadContext to get any kind of error reporting from there.
Want results from more Discord servers?
Add your server