mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
Don't fatalError in NIOTypedHTTPServerUpgraderStateMachine.findingUpgraderCompleted` when the state is `.finished`. ### Motivation: There is a race where the connection can be closed and the NIOTypedHTTPServerUpgraderHandler can be removed setting the state to `.finished` while we are still finding upgraders. And then when `findingUpgraderCompleted` gets called it would fatalError. ### Modifications: - Return `nil` as an action if the state is `.finished` when `findingUpgraderCompleted` is called. - Added a new set of tests which test the `NIOTypedHTTPServerUpgraderStateMachine` directly instead of relying on `HTTPServerUpgraderTests`. I used Swift Testing for these, not sure what NIO policy on new tests are? ### Result: No more crashes and better testing for NIOTypedHTTPServerUpgraderStateMachine --------- Co-authored-by: Cory Benfield <lukasa@apple.com>