fix: event handler exception safety + non-happy-path tests#75
Merged
Conversation
Bug fixes: - Wrap all event invocations in try-catch via RaiseEvent helpers (throwing user handlers no longer crash mux/channels/dispose) - Reject duplicate channel IDs in ChannelRegistry (TryRegisterPendingAcceptChannel uses TryAdd instead of indexer) New tests (92 total): - UnhappyPathTests.cs (53): multiplexer state violations, channel ops after close, cancellation, GoAway, transit errors, lookups - ApiMisuseTests.cs (39): event handler resilience, DuplexStream/ DeltaTransit misuse, concurrent misuse, GoAway+channel, write before ready, AcceptChannel/OpenChannel misuse, stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes event handler exception safety and adds comprehensive non-happy-path test coverage.
Bug Fixes
Event handler exceptions crash the mux (fixed)
All event invocations (
ChannelOpened,ChannelClosed,ChannelAccepted,Connected,Ready,Disconnected,Error,Reconnecting) are now wrapped inRaiseEventhelper methods with try-catch. A throwing user event handler can no longer crash the multiplexer, channels, or dispose.Duplicate channel ID silently broken (fixed)
ChannelRegistry.RegisterPendingAcceptChannelused indexer assignment which silently overwrites. Changed toTryRegisterPendingAcceptChannelwithTryAdd— secondOpenChannel("same")now correctly throwsMultiplexerException(ErrorCode.ChannelExists).New Tests (92)
UnhappyPathTests.cs (53 tests)
ApiMisuseTests.cs (39 tests)
Test Results
393 total tests, 392 pass consistently (1 pre-existing flaky stress test:
ExtremeStressTests.Scale_ConcurrentBidirectional_StressTest).