mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
Motivation: B2MD (in debug mode) has some checking that we never move out of a final state in the state machine. Both .done and .error are final states. Previously however, the code set .done in a defer block which meant that even if the decodeLoop throws (which should bring it to .error), it goes via .done first. That's an error because .done is already a final state so we shouldn't move to .error after that. Modifications: Only move to .done if there was no error. If there was an error, we should go straight to .error, not via .done. Result: - more correct B2MD - fewer crashes (in debug mode)