Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

Implementation Complete: Add dieAll methods to handle pending requests/queries on client termination

  • Add dieAll method to PendingRequests class to die all pending requests with a given error
  • Add dieAll method to PendingQueries class to die all pending queries with a given error
  • Call dieAll on both pending requests and queries before dying the app in SessionExpired cases
  • Call dieAll on both pending requests and queries before dying the app in InvalidCapabilities case
  • Call dieAll on both pending requests and queries before dying the app in ResponseEvicted case
  • Add tests for the new dieAll methods in PendingRequestsSpec and PendingQueriesSpec
  • Run existing tests to ensure no regressions
  • Code review completed
  • Security scan completed
  • Use foreachDiscard instead of foreach().unit (addressed review comments)

Summary

This PR implements the functionality requested in the issue where the RaftClient should die all pending requests and queries when it terminates due to SessionExpired, ResponseEvicted, or InvalidCapabilities.

Changes Made:

  1. PendingRequests.scala: Added dieAll(error: Throwable): UIO[Unit] method that dies all pending request promises with the given error using ZIO.foreachDiscard
  2. PendingQueries.scala: Added dieAll(error: Throwable): UIO[Unit] method that dies all pending query promises with the given error using ZIO.foreachDiscard
  3. RaftClient.scala: Updated 5 locations where the client dies to call dieAll on both pending requests and queries before terminating
  4. Test files: Added comprehensive tests for the new dieAll methods

All 36 tests pass successfully. The implementation ensures that when the client decides to die, all pending requests and queries are properly terminated with an appropriate error before the client shuts down.

Original prompt

This section details on the original issue you should resolve

<issue_title>client should promise.die all pending requests when receiving session expired</issue_title>
<issue_description>When RaftClient decides to die because of SessionExpired, ResponseEvicted or InvalidCapabilities the raft client should also die all pending requests and queries.

We should add dieAll to pending-queries and pending-requests and call it before we die the entire app.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add dieAll to pending queries and requests on session expiration Die all pending requests/queries when client terminates Oct 28, 2025
Copilot AI requested a review from somdoron October 28, 2025 18:06
Copilot finished work on behalf of somdoron October 28, 2025 18:06
@somdoron
Copy link
Contributor

@copilot please address two comments

Copilot AI requested a review from somdoron October 28, 2025 18:24
Copilot finished work on behalf of somdoron October 28, 2025 18:24
@somdoron somdoron marked this pull request as ready for review October 28, 2025 18:26
@somdoron somdoron requested a review from keisar October 28, 2025 18:27
@keisar keisar merged commit a124cd9 into main Oct 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client should promise.die all pending requests when receiving session expired

3 participants