Conversation
dispose of the TransportService correctly in case of disconnections; Signed-off-by: Níckolas Goline <nickolas.goline+github@gmail.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves the robustness of connection handling by adding proper socket state detection, enhancing error handling during disconnections, and implementing proper resource disposal patterns.
- Added an
IsSocketConnected()method to detect dropped TCP connections - Improved exception handling and resource cleanup in TransportService and MessageService
- Enhanced connection state validation throughout the handshake and message processing flow
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/NLightning.Node/Program.cs | Added global unhandled exception logging |
| src/NLightning.Infrastructure/Transport/Services/TransportService.cs | Added socket connection validation and improved buffer management with ArrayPool |
| src/NLightning.Infrastructure/Transport/Handshake/States/HandshakeState.cs | Minor comment update |
| src/NLightning.Infrastructure/Protocol/Services/MessageService.cs | Enhanced exception handling and thread-safe disposal |
| src/NLightning.Infrastructure/Node/Services/PeerService.cs | Added error handling during initialization |
| src/NLightning.Infrastructure/Node/Services/PeerCommunicationService.cs | Improved disconnection handling and ping service management |
| src/NLightning.Infrastructure/Node/Factories/PeerServiceFactory.cs | Added proper resource disposal on connection failures |
| src/NLightning.Domain/Protocol/Interfaces/IMessageService.cs | Added throwOnException parameter to SendMessageAsync |
| src/NLightning.Application/Node/Managers/PeerManager.cs | Added error handling during peer disconnection |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/NLightning.Infrastructure/Transport/Services/TransportService.cs
Outdated
Show resolved
Hide resolved
src/NLightning.Infrastructure/Node/Services/PeerCommunicationService.cs
Outdated
Show resolved
Hide resolved
src/NLightning.Infrastructure/Node/Services/PeerCommunicationService.cs
Outdated
Show resolved
Hide resolved
|
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.
Closes #55
Add a method to check if the TCP connection is open;
Dispose of the TransportService correctly in case of disconnections;