ld-eventsource 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 294a32bc78de81b8f7c5ffa0a8b9ffc25847b0ecd20eee8f27caea576ae2b6fc
4
- data.tar.gz: 5c0bb7736f090364098525477ec192b89ee02b96e0d12542bf72f08112180ba2
3
+ metadata.gz: 63f2bcc65635183d4d5499f1d2d1ade11151293ee4a289d7f824667c7aa9e0f4
4
+ data.tar.gz: a9d9f0ab5bc24b4f04e6222d4e3d87cdf07814ef1c4721ef874c1cf1439ac3e4
5
5
  SHA512:
6
- metadata.gz: b6466b0b4c060b681640e2b47cc1844bb93a9588076fbcc901a5922be303860538d6e064d1f9ea897062ffeafcb86690e68e26e0c28d6f795ea68bb41dc7d364
7
- data.tar.gz: 67a62d448f673893e9fc397cb536ad6ba4194292e3f8c3058d96bcc39b0f8bf3ce6bf12b1bdeb8e843ff962e3324505b9cddc3e42486cdb915456dbe1dba4dcc
6
+ metadata.gz: 97183f611132a017c66069336bf36e920ee83ac5fbfde1955f451cda6e25ed58b9cf3817bd0bc72575c682763084a36a6c90d8915a9c826ac4d82340f97d8c63
7
+ data.tar.gz: 9b521be3f883ed8c7a53410ce1e71932680af30fe13901ac1489c7957a46575ca2906df59c1eb2049a65a49147f02f0935785b432db97918cdf2893853c0d000
@@ -72,7 +72,9 @@ jobs:
72
72
  rvm use $i;
73
73
  if [[ $i == jruby* ]]; then
74
74
  gem install jruby-openssl; # required by bundler, no effect on Ruby MRI
75
- fi
75
+ fi;
76
+ # bundler 2.0 may be preinstalled, we need to remove it if slow
77
+ yes | gem uninstall bundler --version '>=2.0' || true;
76
78
  gem install bundler -v "~> 1.17";
77
79
  bundle install;
78
80
  mv Gemfile.lock "Gemfile.lock.$i"
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to the LaunchDarkly SSE Client for Ruby will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## [1.0.1] - 2019-07-10
6
+ ### Fixed:
7
+ - Calling `close` on the client could cause a misleading warning message in the log, such as `Unexpected error from event source: #<IOError: stream closed in another thread>`.
8
+
5
9
  ## [1.0.0] - 2019-01-03
6
10
 
7
11
  Initial release.
@@ -186,12 +186,14 @@ module SSE
186
186
  # connected but before @cxn was set. Checking the variable again is a bit clunky but avoids that.
187
187
  return if @stopped.value
188
188
  read_stream(@cxn) if !@cxn.nil?
189
- rescue Errno::EBADF
190
- # Don't log this as an error - it probably means we closed our own connection deliberately
191
- @logger.info { "Stream connection closed" }
192
- rescue StandardError => e
193
- # This should not be possible because connect catches all StandardErrors
194
- log_and_dispatch_error(e, "Unexpected error from event source")
189
+ rescue => e
190
+ # When we deliberately close the connection, it will usually trigger an exception. The exact type
191
+ # of exception depends on the specific Ruby runtime. But @stopped will always be set in this case.
192
+ if @stopped.value
193
+ @logger.info { "Stream connection closed" }
194
+ else
195
+ log_and_dispatch_error(e, "Unexpected error from event source")
196
+ end
195
197
  end
196
198
  begin
197
199
  @cxn.close if !@cxn.nil?
@@ -210,6 +212,7 @@ module SSE
210
212
  @logger.info { "Will retry connection after #{'%.3f' % interval} seconds" }
211
213
  sleep(interval)
212
214
  end
215
+ cxn = nil
213
216
  begin
214
217
  @logger.info { "Connecting to event stream at #{@uri}" }
215
218
  cxn = Impl::StreamingHTTPConnection.new(@uri,
@@ -235,11 +238,9 @@ module SSE
235
238
  err = Errors::HTTPStatusError.new(cxn.status, body)
236
239
  @on[:error].call(err)
237
240
  end
238
- rescue Errno::EBADF
239
- raise # See EBADF comment in run_stream
240
- rescue StandardError => e
241
+ rescue
241
242
  cxn.close if !cxn.nil?
242
- log_and_dispatch_error(e, "Unexpected error from event source")
243
+ raise # will be handled in run_stream
243
244
  end
244
245
  # if unsuccessful, continue the loop to connect again
245
246
  end
@@ -1,3 +1,3 @@
1
1
  module SSE
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -112,6 +112,29 @@ EOT
112
112
  end
113
113
  end
114
114
 
115
+ it "does not trigger an error when stream is closed" do
116
+ events_body = simple_event_1_text + simple_event_2_text
117
+ with_server do |server|
118
+ server.setup_response("/") do |req,res|
119
+ send_stream_content(res, events_body, keep_open: true)
120
+ end
121
+
122
+ event_sink = Queue.new
123
+ error_sink = Queue.new
124
+ client = subject.new(server.base_uri) do |c|
125
+ c.on_event { |event| event_sink << event }
126
+ c.on_error { |error| error_sink << error }
127
+ end
128
+
129
+ with_client(client) do |client|
130
+ event_sink.pop # wait till we have definitely started reading the stream
131
+ client.close
132
+ sleep 0.25 # there's no way to really know when the stream thread has finished
133
+ expect(error_sink.empty?).to be true
134
+ end
135
+ end
136
+ end
137
+
115
138
  it "reconnects after error response" do
116
139
  events_body = simple_event_1_text
117
140
  with_server do |server|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ld-eventsource
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-05 00:00:00.000000000 Z
11
+ date: 2019-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -157,8 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
159
  requirements: []
160
- rubyforge_project:
161
- rubygems_version: 2.7.6
160
+ rubygems_version: 3.0.3
162
161
  signing_key:
163
162
  specification_version: 4
164
163
  summary: LaunchDarkly SSE client