mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Motivation: @pushkarnk hit an interesting edge case that we previously mishandled and crashed. All these conditions need to be true 1. Whilst have an ongoing request (ie. outstanding response), ... 2. ... a `HTTPParserError` arrives (which we correctly queue) 3. Later the outstanding response is completed and then ... 4. ... the `HTTPServerProtocolErrorHandler` sends a .badRequest response We previously crashed. The reason we crashed is that the `HTTPServerPipelineHandler` obviously tracks state and then asserts that no response is sent for a wrong request. It does have an affordance to allow a .badRequest response for a request it couldn't parse. However this state tracking wasn't done if the error itself was enqueued for later delivery. Thanks very much @pushkarnk for the report! Modifications: instead of delivering the error directly use the `deliverOneError` function which transitions the state correctly. Result: fewer crashes & hopefully happy Pushkar