Files
swift-nio/Sources/NIOHTTP1
Adam FowlerandCory Benfield 9670fe1d68 Don't fatalError if NIOTypedHTTPServerUpgraderStateMachine is in state finished when finding upgrader (#3597)
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>
2026-05-21 13:41:50 +00:00
..
2026-05-20 10:00:56 +01:00