[refactor] More robust cleanup for websocket connection#11549
Merged
sfc-gh-bnisco merged 1 commit intodevelopfrom Jun 6, 2025
Merged
[refactor] More robust cleanup for websocket connection#11549sfc-gh-bnisco merged 1 commit intodevelopfrom
sfc-gh-bnisco merged 1 commit intodevelopfrom
Conversation
Contributor
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
Contributor
✅ PR preview is ready!
|
a4daf15 to
58ee871
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the WebSocket connection cleanup logic to make the ping mechanism more robust by introducing an async ping request object with cancellation support. Key changes include:
- Returning an object with both promise and cancel from doInitPings.
- Updating the WebsocketConnection class to store and manage an AsyncPingRequest.
- Refactoring associated tests to destructure and await the promise from the new ping API.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/connection/src/WebsocketConnection.tsx | Updated pingServer and disconnect methods to use an AsyncPingRequest. |
| frontend/connection/src/WebsocketConnection.test.tsx | Modified tests to extract the promise from the new doInitPings return. |
| frontend/connection/src/DoInitPings.tsx | Changed the return type to AsyncPingRequest and added a cancel method. |
Comments suppressed due to low confidence (2)
frontend/connection/src/WebsocketConnection.tsx:342
- Consider adding an inline comment explaining the rationale behind storing the full AsyncPingRequest (with both promise and cancel) on the connection. This would aid maintainability and clarify the new ping cancellation logic.
this.pingRequest = doInitPings(
frontend/connection/src/WebsocketConnection.test.tsx:963
- It would be beneficial to add a test case that verifies the ping request is cancelled when disconnect() is called, ensuring the new cancellation behavior is properly covered.
client.disconnect()
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.
Describe your changes
doInitPingsfunction. Wires up the source to call into it.GitHub Issue Link (if applicable)
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.