-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log internal ActionDispatch::DebugExceptions errors #29131
Log internal ActionDispatch::DebugExceptions errors #29131
Conversation
r? @matthewd (@rails-bot has picked a reviewer for you, use r? to override) |
7291858
to
7dcc1c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few small docs comments :)
|
||
# If we got to this point, the only thing that can crash is the | ||
# render_exception method. As private as it is, it's monkey patched by a | ||
# lot of plugins, that need to interact with application errors, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️ the comma between plugins
and that
@@ -66,7 +66,21 @@ def call(env) | |||
response | |||
rescue Exception => exception | |||
raise exception unless request.show_exceptions? | |||
render_exception(request, exception) | |||
|
|||
# If we got to this point, the only thing that can crash is the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we try and pare this down a little bit, to just the essential? I feel like if people want the whole story, we should look at the commit for context 😬 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think so too, wrote it before the commit. I'll drop it, the PR is descriptive enough.
7dcc1c7
to
4bf5532
Compare
What happens when your last resort error handling code crashes by itself? This is a good question. Currently, Rails tries really hard to at least show something to the browsers and not leave the end users with a blank page. For this to happen we have a carefully arranged chain of middlewares that can: - show developer friendly information about an error - show a generic fallback (`Something went wrong`) error response We do try really hard to make sure those middlewares don't crash, however sometimes they do. Most of the time, it's not even Rails' fault. For example the `ActionDispatch::DebugExceptions#render_exception`, as private as it is, it's commonly freedom patched by a lot of plugins, that need to interact with application errors, web-console included. The API of the render_exception method has changed in the past, and it can change in the future. This may be a common place of errors during upgrades. Previously, when `ActionDispatch::DebugExceptions` crashes, the default fallback error response defined in `ActionDispatch::ShowExceptions` kicks in. However, the internal error is not logged anywhere and this may throw a lot of Rails developers into limbo. What is going on? Have I done something? What's the error? For someone unfamiliar with the stack, this is quite the mysterious problem. We have had crashes in web-console and we have tried to tackle them with solutions like rails/web-console#181. This is a more general solution that can benefit all the plugins relying on overriding `#render_exception`. Now, when the plugins or `ActionDispatch::DebugExceptions` itself crashes, we will try very hard to log the internal error to the logs itself or the `stderr` if none of the standard logs have been initialized when the crash occurred.
4bf5532
to
3639069
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
What happens when your last resort error handling code crashes by
itself? This is a good question. Currently, Rails tries really hard to
at least show something to the browsers and not leave the end users with
a blank page.
For this to happen we have a carefully arranged chain of middlewares
that can:
Something went wrong
) error responseWe do try really hard to make sure those middlewares don't crash,
however sometimes they do. Most of the time, it's not even Rails' fault.
For example the
ActionDispatch::DebugExceptions#render_exception
, asprivate as it is, it's commonly freedom patched by a lot of plugins,
that need to interact with application errors, web-console included.
The API of the render_exception method has changed in the past, and it
can change in the future. This may be a common place of errors during
upgrades.
Previously, when
ActionDispatch::DebugExceptions
crashes, the defaultfallback error response defined in
ActionDispatch::ShowExceptions
kicks in. However, the internal error is not logged anywhere and this
may throw a lot of Rails developers into limbo. What is going on? Have
I done something? What's the error?
For someone unfamiliar with the stack, this is quite the mysterious
problem. We have had crashes in web-console and we have tried to tackle
them with solutions like rails/web-console#181. This is a more general
solution that can benefit all the plugins relying on overriding
#render_exception
.Now, when the plugins or
ActionDispatch::DebugExceptions
itselfcrashes, we will try very hard to log the internal error to the logs
itself or the
stderr
if none of the standard logs have beeninitialized when the crash occurred.