Skip to content

Commit f706cc8

Browse files
authored
Merge pull request #542 from koic/fix_flaky_listen_keepalive_thread_assertion
Fix the flaky thread count assertion in the listen keepalive test
2 parents 6d272df + 09c3103 commit f706cc8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎test/mcp/server/transports/streamable_http_transport_test.rb‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6307,10 +6307,13 @@ def string
63076307
end
63086308

63096309
test "listen keepalive is not started when the interval is nil" do
6310-
before = Thread.list.size
6310+
# The set of threads, not their count: `Thread.list` is process-wide, so a thread another test left running
6311+
# that finishes between the two samples moves the count in the direction this assertion does not care about.
6312+
# Only a thread that appears is evidence of a keepalive timer.
6313+
before = Thread.list
63116314
open_listen_stream(id: "listen-1", notifications: { toolsListChanged: true })
63126315

6313-
assert_equal before, Thread.list.size, "a nil interval must not spawn a keepalive thread"
6316+
assert_empty(Thread.list - before, "a nil interval must not spawn a keepalive thread")
63146317
end
63156318

63166319
test "listen_keepalive_interval rejects a non-positive value" do

0 commit comments

Comments
 (0)