-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Include more information on AlreadySentError errors #6000
base: main
Are you sure you want to change the base?
Include more information on AlreadySentError errors #6000
Conversation
ad557ca
to
ad5174a
Compare
lib/phoenix/controller.ex
Outdated
@@ -642,7 +642,9 @@ defmodule Phoenix.Controller do | |||
if state in @unsent do | |||
put_private_layout(conn, :phoenix_layout, :replace, layout) | |||
else | |||
raise AlreadySentError | |||
raise AlreadySentError, """ | |||
The response was already sent. Request was to `#{conn.request_path}` using #{inspect(layout)}\ |
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 request path should be in your logs/error handler anyway. Suggestion is to add information like the status code instead and response information.
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.
Ping :)
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.
Ah sorry, thanks for the reminder! I have pushed a thing see what you think :)
Adds more information to the AlreadySentError to help make debugging them easier.
ad5174a
to
ad5136a
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.
One comment and we should be good to go!
lib/phoenix/controller.ex
Outdated
The response was already sent. | ||
|
||
Status code: `#{conn.status}` | ||
Request path: `#{conn.request_path}` | ||
Method: `#{conn.method}` | ||
View module: `#{inspect(module)}` |
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.
Error messages start in lowercase and I think the backticks would make things harder to read, so I suggest removing them:
The response was already sent. | |
Status code: `#{conn.status}` | |
Request path: `#{conn.request_path}` | |
Method: `#{conn.method}` | |
View module: `#{inspect(module)}` | |
the response was already sent. | |
Status code: #{conn.status} | |
Request path: #{conn.request_path} | |
Method: #{conn.method} | |
View module: #{inspect(module)} |
ad51317
to
ad56eef
Compare
We have an app that is getting a lot of AlreadySentErrors. Likely somewhere we have missed an
halt()
, but tracking that down is tricky. I wonder if we could supply some more information in the various places the error gets raised to help someone debug the issue? I have supplied a small example, but the exact wording and contents can be discussed.I'm happy to roll this out to more places if we agree it's a good idea.