Skip to content
8 changes: 4 additions & 4 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def with_client(client)
yield client
ensure
client.close
# Wait for SSE worker thread to terminate before next test reuses the port
Thread.list.select { |t| t.name == 'LD/SSEClient' }.each { |t| t.join(1) }
end
end

Expand Down Expand Up @@ -1124,7 +1126,7 @@ def test_object.to_s
requests << request_data
attempt += 1
if attempt == 1
send_stream_content(res, "", keep_open: false) # Close to trigger reconnect
send_stream_content(res, ": keepalive\n\n", keep_open: false) # Close to trigger reconnect
else
send_stream_content(res, "", keep_open: true)
end
Expand Down Expand Up @@ -1334,9 +1336,7 @@ def test_object.to_s
requests << request_data
attempt += 1
if attempt <= 2
res.status = 500
res.body = "error"
res.keep_alive = false
send_stream_content(res, ": ping\n\n", keep_open: false) # Close to trigger reconnect
else
send_stream_content(res, "", keep_open: true)
end
Expand Down
2 changes: 2 additions & 0 deletions spec/headers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def with_client(client)
yield client
ensure
client.close
# Wait for SSE worker thread to terminate before next test reuses the port
Thread.list.select { |t| t.name == 'LD/SSEClient' }.each { |t| t.join(1) }
end
end

Expand Down
Loading