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 handling in the Http4sNettyHandler #395

Merged
merged 5 commits into from
Jan 25, 2023

Conversation

bryce-anderson
Copy link
Member

Problem

There are a couple things wrong with error handling in the
Http4sNettyHandler.

  • The sendSimpleErrorResponse method doesn't flush the message so the
    pipeline will stall out in the common case.
  • The recover block in the Future composition that is part of the
    channelRead method suggests it's for handling failed writes but
    thats not the case: write failures will bubble up through the netty
    ChannelFuture, not be throw synchronously. The errors that will be
    propagated to the recover block will be things that passed by the
    ServiceErrorHandler, which should be considered 500's and probably
    represent a configuration issue.

Solution

Flush our error responses and refactor the error handling in the Future
composition blocks.
Also add a test.

Problem

There are a couple things wrong with error handling in the
Http4sNettyHandler.
- The `sendSimpleErrorResponse` method doesn't flush the message so the
  pipeline will stall out in the common case.
- The recover block in the Future composition that is part of the
  `channelRead` method suggests it's for handling failed writes but
  thats not the case: write failures will bubble up through the netty
  ChannelFuture, not be throw synchronously. The errors that will be
  propagated to the recover block will be things that passed by the
  `ServiceErrorHandler`, which should be considered 500's and probably
  represent a configuration issue.

Solution

Flush our error responses and refactor the error handling in the Future
composition blocks.
Also add a test.
@hamnis
Copy link
Collaborator

hamnis commented Jan 25, 2023

Failure is unrelated to this fix.

@hamnis hamnis merged commit 3193c73 into http4s:series/0.5 Jan 25, 2023
@bryce-anderson bryce-anderson deleted the ServiceErrorHandling branch January 25, 2023 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants