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

Deliver outbound stream errors to channels. #315

Merged
merged 2 commits into from
Nov 26, 2021

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Nov 26, 2021

Motivation:

When we hit a stream error on an outbound frame, we don't currently
distinguish between them and channel errors. This makes it impossible
for anyone to tell them apart. It also makes it impossible for the
multiplexer to deliver these errors into the relevant stream channels
that triggered them, making it essentially certain they'll be lost.

Better diagnostics would be good, so we are providing them.

Modifications:

  • Add new StreamError type that carries a stream ID and an underlying
    error.
  • Emit this StreamError type for outbound stream errors.
  • Deliver this StreamError type into the relevant child channels when
    possible.

Result:

Better diagnostics for stream errors.

Motivation:

When we hit a stream error on an outbound frame, we don't currently
distinguish between them and channel errors. This makes it impossible
for anyone to tell them apart. It also makes it impossible for the
multiplexer to deliver these errors into the relevant stream channels
that triggered them, making it essentially certain they'll be lost.

Better diagnostics would be good, so we are providing them.

Modifications:

- Add new StreamError type that carries a stream ID and an underlying
  error.
- Emit this StreamError type for outbound stream errors.
- Deliver this StreamError type into the relevant child channels when
  possible.

Result:

Better diagnostics for stream errors.
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Nov 26, 2021
Comment on lines +209 to +212
if let streamError = error as? NIOHTTP2Errors.StreamError,
let channel = self.streams[streamError.streamID] {
channel.receiveStreamError(streamError)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to receive a stream error for a stream we don't know about? Wondering whether we should drop stream errors for streams we aren't aware of (to avoid downstream handlers, for example, closing the channel on receiving an error).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is, but I don't think we should drop them. Just because the multiplexer doesn't know about them doesn't mean the error is not of interest.

Copy link
Member

@dnadoba dnadoba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one question.

channel.receiveStreamError(streamError)
}

context.fireErrorCaught(error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to unconditionaly forward it to the next channel handler even if we deliver it to one of our child channels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we probably do: this ensures that errors don't suddenly go missing when they were reported before.

@Lukasa Lukasa merged commit f0adfc1 into apple:main Nov 26, 2021
@Lukasa Lukasa deleted the cb-better-errors-on-invalid-stream branch November 26, 2021 17:38
@fabianfett
Copy link
Member

Even though, to late to the game... 👍 Great change, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants