Skip to content
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

Fix error in EventHandler on request with error #1114

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

tombruijn
Copy link
Member

When a request has an error, it would give the on_finish callback a response object that is nil.

This would break when we called response.status, and it would fail to complete the transaction.

Make sure the transaction is always completed by putting the complete_current! call in ensure blocks.

Check if the response object is nil before calling other methods on it to the response status tag and metric. This way we don't raise an error.

Luckily no integrations of ours that have been published yet would run into this behavior. The Rails integrations uses the EventHandler, but has its own error reporting.

This would only be a problem for people who use the EventHandler directly, or when we move more integrations over to use AbstractMiddleware subclasses.

When a request has an error, it would give the `on_finish` callback a
response object that is `nil`.

This would break when we called `response.status`, and it would fail to
complete the transaction.

Make sure the transaction is always completed when it's handling a
transaction, by putting the outside the safety block which fetches all
the request and response metadata.

Check if the `response` object is `nil` before calling other
methods on it to the response status tag and metric. This way we don't
raise an error.

Luckily no integrations of ours that have been published yet would run
into this behavior. The Rails integrations uses the EventHandler, but
has its own error reporting.

This would only be a problem for people who use the EventHandler
directly, or when we move more integrations over to use
AbstractMiddleware subclasses.
@tombruijn tombruijn force-pushed the rack-eventhandler-errors branch from 7f6c1e9 to 9e6a3d4 Compare June 25, 2024 14:05
@tombruijn tombruijn merged commit 0e48f19 into main Jun 26, 2024
16 checks passed
@tombruijn tombruijn deleted the rack-eventhandler-errors branch July 10, 2024 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants