Skip to content

Commit 3efb7b7

Browse files
committed
polish
1 parent 45cf15d commit 3efb7b7

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

lib/splitclient-rb/sse/event_source/client.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def close(status = nil)
4444
@config.logger.debug("Closing SSEClient socket")
4545

4646
@connected.make_false
47-
@socket.sync_close = true
47+
@socket.sync_close = true if @socket.is_a? OpenSSL::SSL::SSLSocket
4848
@socket.close
49-
@config.logger.debug("SSEClient socket state #{@socket.state}")
49+
@config.logger.debug("SSEClient socket state #{@socket.state}") if @socket.is_a? OpenSSL::SSL::SSLSocket
5050
push_status(status)
5151
rescue StandardError => e
5252
@config.logger.error("SSEClient close Error: #{e.inspect}")
@@ -60,7 +60,6 @@ def start(url)
6060

6161
@uri = URI(url)
6262
latch = Concurrent::CountDownLatch.new(1)
63-
6463
connect_thread(latch)
6564

6665
return false unless latch.wait(CONNECT_TIMEOUT)
@@ -108,6 +107,7 @@ def connect_stream(latch)
108107
@config.logger.error("SSE read operation timed out!: #{e.inspect}")
109108
return Constants::PUSH_RETRYABLE_ERROR
110109
rescue EOFError => e
110+
puts "SSE read operation EOF Exception!: #{e.inspect}"
111111
@config.logger.error("SSE read operation EOF Exception!: #{e.inspect}")
112112
raise 'eof exception'
113113
rescue Errno::EBADF, IOError => e
@@ -126,7 +126,11 @@ def connect_stream(latch)
126126
end
127127
rescue Errno::EBADF
128128
@config.logger.debug("SSE socket is not connected (Errno::EBADF)")
129-
finally
129+
break
130+
rescue RuntimeError
131+
raise 'eof exception'
132+
rescue Exception => e
133+
@config.logger.debug("SSE socket is not connected: #{e.inspect}")
130134
break
131135
end
132136

spec/sse/sse_handler_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
config.streaming_service_url = server.base_uri
5050
sse_handler = subject.new(config, splits_worker, segments_worker, sse_client)
51-
5251
connected = sse_handler.start('token-test', 'channel-test')
5352
expect(connected).to eq(true)
5453
expect(sse_handler.connected?).to eq(true)

0 commit comments

Comments
 (0)