ably 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f26db73bc52944f7e282d9946c31d3c3cca0c12e922a6fdf12fbf017c825c850
4
- data.tar.gz: dddf1e3c6fc8bfec7290d75f7da54bdf4c1d126f3a9c2b55a07addfad55f8de7
3
+ metadata.gz: 16e7e84ef48f6781cea03494b8b603b6e59cf98583ad1200f0421dab0bc0252d
4
+ data.tar.gz: 39dc6cd4bba9d31f8bd7f94f31c75b97adce21bf1fe07bbf0b3701a0f7075a59
5
5
  SHA512:
6
- metadata.gz: e9db81f7b4f556708cd4e8e23538266c211b28b726081dba5a4e7022f108f0235bb37b10ab393208266c3aa44eceb1fc599c3cfaef62e85052d5a3371e7ff91b
7
- data.tar.gz: c17bf2a1c5db04329d04684ffe39cbdc339e29f5e88fc3059d2b0f70549d07cdd5262d891c146f28fce47969fad9612c6dc70f3203a48ef57f847fbf7cb6e145
6
+ metadata.gz: 919eaa8f22a8178997e3505b449e03d93824196803aae58ceee9a55220e2199b4a911edad93a1563e225a167c79ec336c18983a4d0bbbd6d9626657b3acf98a9
7
+ data.tar.gz: 44ff62c2c39e022133039f7e04a52d839fb3d50abf344cd3da3ba1ec8890f51c4e532813a2ea138e78556027a133477d60d01bf839e37ca9183b126a007cff82
@@ -32,8 +32,9 @@ jobs:
32
32
  run: |
33
33
  mkdir junit
34
34
  bundle exec parallel_rspec --prefix-output-with-test-env-number --first-is-1 -- spec/${{ matrix.type }}
35
- - uses: actions/upload-artifact@v3
35
+ - uses: actions/upload-artifact@v4
36
36
  with:
37
+ name: test-results-ruby-${{ matrix.ruby }}-${{ matrix.protocol }}-${{ matrix.type }}
37
38
  path: |
38
39
  junit/
39
40
  coverage/
@@ -45,7 +46,7 @@ jobs:
45
46
  server-url: 'https://test-observability.herokuapp.com'
46
47
  server-auth: ${{ secrets.TEST_OBSERVABILITY_SERVER_AUTH_KEY }}
47
48
  path: 'junit/'
48
- - uses: coverallsapp/github-action@1.1.3
49
+ - uses: coverallsapp/github-action@v2
49
50
  with:
50
51
  github-token: ${{ secrets.GITHUB_TOKEN }}
51
52
  flag-name: ruby-${{ matrix.ruby }}-${{ matrix.protocol }}-${{ matrix.type }}
@@ -55,7 +56,7 @@ jobs:
55
56
  runs-on: ubuntu-latest
56
57
  steps:
57
58
  - name: Coveralls Finished
58
- uses: coverallsapp/github-action@1.1.3
59
+ uses: coverallsapp/github-action@v2
59
60
  with:
60
61
  github-token: ${{ secrets.github_token }}
61
62
  parallel-finished: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.2.8](https://github.com/ably/ably-ruby/tree/v1.2.8)
4
+
5
+ [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.2.7...v1.2.8)
6
+
7
+ **Fixed bugs:**
8
+
9
+ * Fix incompatibility with `websocket-driver` 0.8 (#443)
10
+ * Do not use fallback hosts as a result of a token error (#443)
11
+
12
+ **Updated dependencies:**
13
+
14
+ * Bump `faraday-typhoeus` to 1.1.0 (#442)
15
+
3
16
  ## [v1.2.7](https://github.com/ably/ably-ruby/tree/v1.2.7)
4
17
 
5
18
  [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.2.6...v1.2.7)
data/SPEC.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ably Realtime & REST Client Library 1.2.7 Specification
1
+ # Ably Realtime & REST Client Library 1.2.8 Specification
2
2
 
3
3
  ### Ably::Realtime::Auth
4
4
  _(see [spec/acceptance/realtime/auth_spec.rb](./spec/acceptance/realtime/auth_spec.rb))_
@@ -646,7 +646,7 @@ _(see [spec/acceptance/realtime/connection_failures_spec.rb](./spec/acceptance/r
646
646
  * authentication failure
647
647
  * when API key is invalid
648
648
  * with invalid app part of the key
649
- * [enters the failed state and returns a not found error](./spec/acceptance/realtime/connection_failures_spec.rb#L29)
649
+ * [enters the failed state and returns an invalid credentials error](./spec/acceptance/realtime/connection_failures_spec.rb#L29)
650
650
  * with invalid key name part of the key
651
651
  * [enters the failed state and returns an authorization error](./spec/acceptance/realtime/connection_failures_spec.rb#L44)
652
652
  * with auth_url
@@ -2323,16 +2323,16 @@ _(see [spec/acceptance/rest/base_spec.rb](./spec/acceptance/rest/base_spec.rb))_
2323
2323
  * using JSON protocol
2324
2324
  * failed requests
2325
2325
  * due to invalid Auth
2326
- * [should raise an InvalidRequest exception with a valid error message and code](./spec/acceptance/rest/base_spec.rb#L75)
2326
+ * [should raise an UnauthorizedRequest exception with a valid error message and code](./spec/acceptance/rest/base_spec.rb#L75)
2327
2327
  * server error with JSON error response body
2328
- * [should raise a ServerError exception](./spec/acceptance/rest/base_spec.rb#L96)
2328
+ * [should raise a ServerError exception](./spec/acceptance/rest/base_spec.rb#L95)
2329
2329
  * 500 server error without a valid JSON response body
2330
- * [should raise a ServerError exception](./spec/acceptance/rest/base_spec.rb#L109)
2330
+ * [should raise a ServerError exception](./spec/acceptance/rest/base_spec.rb#L108)
2331
2331
  * token authentication failures
2332
2332
  * when auth#token_renewable?
2333
- * [should automatically reissue a token](./spec/acceptance/rest/base_spec.rb#L147)
2333
+ * [should automatically reissue a token](./spec/acceptance/rest/base_spec.rb#L146)
2334
2334
  * when NOT auth#token_renewable?
2335
- * [should raise an TokenExpired exception](./spec/acceptance/rest/base_spec.rb#L162)
2335
+ * [should raise an TokenExpired exception](./spec/acceptance/rest/base_spec.rb#L161)
2336
2336
 
2337
2337
  ### Ably::Rest::Channel
2338
2338
  _(see [spec/acceptance/rest/channel_spec.rb](./spec/acceptance/rest/channel_spec.rb))_
@@ -3100,7 +3100,7 @@ _(see [spec/acceptance/rest/presence_spec.rb](./spec/acceptance/rest/presence_sp
3100
3100
  * default :limit
3101
3101
  * [defaults to a limit of 100](./spec/acceptance/rest/presence_spec.rb#L86)
3102
3102
  * with :client_id option
3103
- * FAILED: ~~[returns a list members filtered by the provided client ID](./spec/acceptance/rest/presence_spec.rb#L95)~~
3103
+ * [returns a list members filtered by the provided client ID](./spec/acceptance/rest/presence_spec.rb#L95)
3104
3104
  * with :connection_id option
3105
3105
  * [returns a list members filtered by the provided connection ID](./spec/acceptance/rest/presence_spec.rb#L106)
3106
3106
  * [returns a list members filtered by the provided connection ID](./spec/acceptance/rest/presence_spec.rb#L110)
@@ -5075,6 +5075,6 @@ _(see [spec/unit/util/pub_sub_spec.rb](./spec/unit/util/pub_sub_spec.rb))_
5075
5075
 
5076
5076
  ## Test summary
5077
5077
 
5078
- * Passing tests: 2494
5078
+ * Passing tests: 2495
5079
5079
  * Pending tests: 5
5080
- * Failing tests: 1
5080
+ * Failing tests: 0
data/ably.gemspec CHANGED
@@ -22,10 +22,11 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency 'ably-em-http-request', '~> 1.1.8'
23
23
  spec.add_runtime_dependency 'statesman', '~> 9.0'
24
24
  spec.add_runtime_dependency 'faraday', '~> 2.2'
25
- spec.add_runtime_dependency 'faraday-typhoeus', '~> 0.2.0'
25
+ spec.add_runtime_dependency 'faraday-typhoeus', '~> 1.1.0'
26
26
  spec.add_runtime_dependency 'typhoeus', '~> 1.4'
27
27
  spec.add_runtime_dependency 'json'
28
- spec.add_runtime_dependency 'websocket-driver', '~> 0.7'
28
+ # We disallow minor version updates, because this gem has introduced breaking API changes in minor releases before (which it's within its rights to do, given it's pre-v1). If you want to allow a new minor version, bump here and run the tests.
29
+ spec.add_runtime_dependency 'websocket-driver', '~> 0.8.0'
29
30
  spec.add_runtime_dependency 'msgpack', '>= 1.3.0'
30
31
  spec.add_runtime_dependency 'addressable', '>= 2.0.0'
31
32
 
@@ -257,7 +257,7 @@ module Ably::Realtime
257
257
  when :json
258
258
  JSON.parse(data)
259
259
  when :msgpack
260
- MessagePack.unpack(data.pack('C*'))
260
+ MessagePack.unpack(data)
261
261
  else
262
262
  client.logger.fatal { "WebsocketTransport: Unsupported Protocol Message format #{client.protocol}" }
263
263
  data
@@ -690,16 +690,44 @@ module Ably
690
690
  end
691
691
 
692
692
  def use_fallback_if_disconnected?
693
- second_reconnect_attempt_for(:disconnected, 1)
693
+ unless second_reconnect_attempt_for(:disconnected, 1)
694
+ return false
695
+ end
696
+
697
+ does_error_necessitate_fallback(reason_for_last_time_in(:disconnected))
694
698
  end
695
699
 
696
700
  def use_fallback_if_suspended?
697
- second_reconnect_attempt_for(:suspended, 2) # on first suspended state use default Ably host again
701
+ unless second_reconnect_attempt_for(:suspended, 2) # on first suspended state use default Ably host again
702
+ return false
703
+ end
704
+
705
+ does_error_necessitate_fallback(reason_for_last_time_in(:suspended))
698
706
  end
699
707
 
700
708
  def second_reconnect_attempt_for(state, first_attempt_count)
701
709
  previous_state == state && manager.retry_count_for_state(state) >= first_attempt_count
702
710
  end
711
+
712
+ # Provides a partial implementation of RTN17f's logic for whether an error necessitates a fallback host.
713
+ def does_error_necessitate_fallback(error)
714
+ return false unless error
715
+
716
+ # For now we just explicitly exclude token errors. TODO: implement properly in https://github.com/ably/ably-ruby/issues/444
717
+
718
+ if error.respond_to?(:status_code) && error.status_code == 401 && error.respond_to?(:code) && Ably::Exceptions::TOKEN_EXPIRED_CODE.include?(error.code)
719
+ return false
720
+ end
721
+
722
+ true
723
+ end
724
+
725
+ # Returns the error associated with the last state change to the given state (e.g. :disconnected).
726
+ def reason_for_last_time_in(state)
727
+ history_item = state_history.reverse.find do |history_item|
728
+ history_item.fetch(:state) == state
729
+ end.fetch(:metadata).reason
730
+ end
703
731
  end
704
732
  end
705
733
  end
data/lib/ably/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Ably
2
- VERSION = '1.2.7'
2
+ VERSION = '1.2.8'
3
3
  # The level of compatibility with the Ably service that this SDK supports.
4
4
  # Also referred to as the 'wire protocol version'.
5
5
  # spec : CSV2
@@ -34,7 +34,7 @@ describe Ably::Realtime::Client, :event_machine do
34
34
  client.connection.once(:failed) do
35
35
  expect(custom_logger_object.logs.find do |severity, message|
36
36
  next unless %w(fatal error).include?(severity.to_s)
37
- message.match(%r{https://help.ably.io/error/40400})
37
+ message.match(%r{https://help.ably.io/error/40101})
38
38
  end).to_not be_nil
39
39
  stop_reactor
40
40
  end
@@ -26,13 +26,13 @@ describe Ably::Realtime::Connection, 'failures', :event_machine do
26
26
  context 'with invalid app part of the key' do
27
27
  let(:invalid_key) { 'not_an_app.invalid_key_name:invalid_key_value' }
28
28
 
29
- it 'enters the failed state and returns a not found error' do
29
+ it 'enters the failed state and returns an invalid credentials error' do
30
30
  connection.on(:failed) do |connection_state_change|
31
31
  error = connection_state_change.reason
32
32
  expect(connection.state).to eq(:failed)
33
33
  # TODO: Check error type is an InvalidToken exception
34
- expect(error.status).to eq(404)
35
- expect(error.code).to eq(40400) # not found
34
+ expect(error.status).to eq(401)
35
+ expect(error.code).to eq(40101) # invalid credentials
36
36
  stop_reactor
37
37
  end
38
38
  end
@@ -46,7 +46,7 @@ describe Ably::Realtime::Connection, 'failures', :event_machine do
46
46
  error = connection_state_change.reason
47
47
  expect(connection.state).to eq(:failed)
48
48
  # TODO: Check error type is a TokenNotFound exception
49
- expect(error.status).to eq(401)
49
+ expect(error.status).to eq(404)
50
50
  expect(error.code).to eq(40400) # not found
51
51
  stop_reactor
52
52
  end
@@ -1396,10 +1396,10 @@ describe Ably::Realtime::Connection, 'failures', :event_machine do
1396
1396
  channel = client.channels.get("foo")
1397
1397
  channel.attach do
1398
1398
  connection.once(:failed) do |state_change|
1399
- expect(state_change.reason.code).to eql(40400)
1400
- expect(connection.error_reason.code).to eql(40400)
1399
+ expect(state_change.reason.code).to eql(40101)
1400
+ expect(connection.error_reason.code).to eql(40101)
1401
1401
  expect(channel).to be_failed
1402
- expect(channel.error_reason.code).to eql(40400)
1402
+ expect(channel.error_reason.code).to eql(40101)
1403
1403
  stop_reactor
1404
1404
  end
1405
1405
 
@@ -72,13 +72,12 @@ describe Ably::Rest do
72
72
 
73
73
  describe 'failed requests' do
74
74
  context 'due to invalid Auth' do
75
- it 'should raise an InvalidRequest exception with a valid error message and code' do
75
+ it 'should raise an UnauthorizedRequest exception with a valid error message and code' do
76
76
  invalid_client = Ably::Rest::Client.new(key: 'appid.keyuid:keysecret', environment: environment)
77
77
  expect { invalid_client.channel('test').publish('foo', 'choo') }.to raise_error do |error|
78
- expect(error).to be_a(Ably::Exceptions::ResourceMissing)
79
- expect(error.message).to match(/No application found/)
80
- expect(error.code).to eql(40400)
81
- expect(error.status).to eql(404)
78
+ expect(error).to be_a(Ably::Exceptions::UnauthorizedRequest)
79
+ expect(error.code).to eql(40101)
80
+ expect(error.status).to eql(401)
82
81
  end
83
82
  end
84
83
  end
@@ -33,9 +33,9 @@ describe Ably::Rest::Client do
33
33
  it 'logs an entry with a help href url matching the code #TI5' do
34
34
  begin
35
35
  client.channels.get('foo').publish('test')
36
- raise 'Expected Ably::Exceptions::ResourceMissing'
37
- rescue Ably::Exceptions::ResourceMissing => err
38
- expect err.to_s.match(%r{https://help.ably.io/error/40400})
36
+ raise 'Expected Ably::Exceptions::UnauthorizedRequest'
37
+ rescue Ably::Exceptions::UnauthorizedRequest => err
38
+ expect err.to_s.match(%r{https://help.ably.io/error/40101})
39
39
  end
40
40
  end
41
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ably
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lewis Marshall
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-09-11 00:00:00.000000000 Z
12
+ date: 2025-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 0.2.0
76
+ version: 1.1.0
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 0.2.0
83
+ version: 1.1.0
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: typhoeus
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -115,14 +115,14 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: '0.7'
118
+ version: 0.8.0
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0.7'
125
+ version: 0.8.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: msgpack
128
128
  requirement: !ruby/object:Gem::Requirement