Replies: 6 comments 9 replies
-
Yes, I was going to suggest something like this. Currently Remix simply logs to It would definitely be helpful to include a hook to be able to log server errors. |
Beta Was this translation helpful? Give feedback.
-
Dropping this here in case anyone else stumbles upon this thread: https://twitter.com/mjackson/status/1515351242637152262 |
Beta Was this translation helpful? Give feedback.
-
This patch from @kiliman looks to do exactly what I describe here https://github.com/kiliman/remix-error-logging |
Beta Was this translation helpful? Give feedback.
-
I think Remix should provide more hooks for those that don't want to "eject" to express just to handle things like middleware and proper error handling. The DX of remix-serve is much better than than the express + remix setup. I think adding middleware support for loaders/actions would go a long way here - it would be trivial to hook into the middleware to add performance logging, error reporting, etc. if we had that capability. Right now it seems the recommendation is to just use express, which is unfortunate. |
Beta Was this translation helpful? Give feedback.
-
I would love to have this. Not sure why, but a standard Express error handler middleware is not firing. I would like to log errors so I can be alerted on the error. Also, the current Remix setup just dumps the error into STDERR, which isn't supported by my log pipeline (all logs must be JSON) |
Beta Was this translation helpful? Give feedback.
-
This is now implemented in v1.17.0. |
Beta Was this translation helpful? Give feedback.
-
Proposal
Add an optional export in
entry.server
to receive any uncaught error (errors that triggered an ErrorBoundary) in a centralized place.Background
Right now, Remix catches any error throw by the app to render the matching ErrorBoundary.
That is great but what if I want to send server-side errors to Sentry or something similar?
Right now I had to wrap the loader/action code in a try/catch, catch the error, send it to Sentry and throw the error again (supposing I don't want to handle it and throw a response).
And that only works on loader/action, I will not be able to catch render errors (maybe on entry.server?) because Sentry needs a different SDK for client and server, and since the ErrorBoundary code runs in both sides I would had to initialize both and detect where I'm to use one or the other.
Use Case
API/Example
In
entry.server
add an optional exportThe function could also receive the request object that had the error so we could get info from there to send to Sentry.
With a function like this, I could have a way to know any error I didn't specifically caught, I will still not be able to intercept the response so error boundaries will continue to work but still get proper error reporting.
The idea is the return value of the function is completely ignored, it's an async function only so you can do async work there like parsing the session from the request.
Prior Art
Beta Was this translation helpful? Give feedback.
All reactions