-
Notifications
You must be signed in to change notification settings - Fork 420
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 crashes due to mismatching responses sent to the channel when event observer factories fail. #395
Conversation
…nt observer factories fail.
A review from @glbrntt would be appreciated as well :-) |
Happy to take a look after @glbrntt since he probably has a bit more context on this. |
public override func handlerAdded(ctx: ChannelHandlerContext) { | ||
guard let eventObserver = eventObserver, | ||
let context = context else { return } | ||
// Terminate the call if providing an observer fails. |
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.
I'm not sure I follow this line, do you mean "Terminate the call if the provided observer fails"?
The below explanation is helpful though! 👍
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.
Added "the future [providing an observer]", hope that makes it more clear: Users return a future containing the observer block. This lets them simply fail that future (with a GRPCStatus
) if they do not want to receive messages on this call at all, e.g. in case of authentication failure (e.g. if the request metadata doesn't contain user credentials).
Updated the PR :-) |
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.
Some suggestions, but feel free to merge
@testable import SwiftGRPCNIO | ||
import XCTest | ||
|
||
private let expectedError = GRPCStatus(code: .internalError, message: "expected error") |
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.
nit: Maybe prefix as kExpectedError
since this is a global constant?
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.
Given that this is a private fixture used in just one file, I prefer to not use the k
prefix in this case.
No description provided.