Skip to content

Stabilize RPC subscription tests by fixing shutdown/httptest cleanup order#4275

Merged
AnnaShaleva merged 2 commits into
masterfrom
copilot/fix-test-filtered-subscriptions-timeout
May 22, 2026
Merged

Stabilize RPC subscription tests by fixing shutdown/httptest cleanup order#4275
AnnaShaleva merged 2 commits into
masterfrom
copilot/fix-test-filtered-subscriptions-timeout

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2026

TestFilteredSubscriptions could intermittently hang/timeout on Windows due to websocket lifecycle timing during test teardown. The issue was in test infrastructure cleanup ordering, not subscription filter logic.

  • Root cause addressed: teardown ordering for WS-backed RPC tests

    • Updated wrapUnitTestChain cleanup registration so RPC shutdown runs before httptest.Server close during t.Cleanup execution (LIFO).
    • This avoids leaving websocket/hijacked connection handling in an unsafe shutdown sequence during subtest teardown.
  • Change scope

    • Single-line behavioral change in test helper setup:
      • pkg/services/rpcsrv/server_helper_test.go
  • Code change (illustrative)

    // before
    t.Cleanup(rpcServer.Shutdown)
    t.Cleanup(srv.Close)
    
    // after (LIFO => rpcServer.Shutdown runs first)
    t.Cleanup(srv.Close)
    t.Cleanup(rpcServer.Shutdown)

Copilot AI changed the title [WIP] Fix TestFilteredSubscriptions timeout on Windows Stabilize RPC subscription tests by fixing shutdown/httptest cleanup order May 21, 2026
Copilot AI requested a review from AnnaShaleva May 21, 2026 16:55
Copy link
Copy Markdown
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid one, let's give it a try.

@AnnaShaleva AnnaShaleva marked this pull request as ready for review May 22, 2026 09:14
@AnnaShaleva AnnaShaleva requested a review from roman-khimov as a code owner May 22, 2026 09:14
@AnnaShaleva AnnaShaleva merged commit dc7f428 into master May 22, 2026
32 checks passed
@AnnaShaleva AnnaShaleva deleted the copilot/fix-test-filtered-subscriptions-timeout branch May 22, 2026 09:16
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.49%. Comparing base (e5f1e3f) to head (cacc3b8).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4275      +/-   ##
==========================================
- Coverage   83.50%   83.49%   -0.01%     
==========================================
  Files         359      359              
  Lines       44168    44168              
==========================================
- Hits        36883    36879       -4     
- Misses       5467     5470       +3     
- Partials     1818     1819       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

TestFilteredSubscriptions timeout on Windows

2 participants