@subiz/wsclient 4.0.33 → 4.0.34

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/wsclient",
3
- "version": "4.0.33",
3
+ "version": "4.0.34",
4
4
  "main": "realtime.js",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -16,7 +16,7 @@
16
16
  "description": "",
17
17
  "devDependencies": {
18
18
  "tape": "^5.9.0",
19
- "vite": "^6.3.3",
19
+ "vite": "^6.3.5",
20
20
  "vite-plugin-commonjs": "^0.10.4"
21
21
  },
22
22
  "dependencies": {
package/realtime.js CHANGED
@@ -242,10 +242,10 @@ function Realtime(apiUrls, credential, callAPI, accid, skipautoreconnect) {
242
242
  randomUrl,
243
243
  credential,
244
244
  function (code, body, status) {
245
- if (myconn != conn) return // outdated
245
+ if (conn === undefined || myconn != conn) return // outdated
246
246
  conn = undefined // prevent dupplicate dead fire
247
247
  pubsub.emit('interrupted', code, body, status)
248
- // if (!skipautoreconnect) setTimeout(reconnect, 2000) // reconnect and resubscribe after 2 sec
248
+ if (!skipautoreconnect) setTimeout(reconnect, 2000) // reconnect and resubscribe after 2 sec
249
249
  },
250
250
  function (events) {
251
251
  if (myconn != conn) return
package/realtime.test.js CHANGED
@@ -114,9 +114,9 @@ test.only('realtime', async (t) => {
114
114
  {
115
115
  name: 'starting status',
116
116
  steps: [
117
- {type: 'status', status: 'active'},
117
+ {type: 'status', status: 'connecting'},
118
118
  {type: 'subscribe', topics: ['message_sent']},
119
- {type: 'status', status: 'active'},
119
+ {type: 'status', status: 'connecting'},
120
120
  {type: 'call', call_id: '1', path: '/subs', method: 'post', body: {events: ['message_sent']}},
121
121
  {type: 'wait', timeout: 5000},
122
122
  {type: 'status', status: 'connecting'},
@@ -130,7 +130,7 @@ test.only('realtime', async (t) => {
130
130
  name: 'long subscribe',
131
131
  steps: [
132
132
  {type: 'subscribe', topics: ['message_sent']},
133
- {type: 'status', status: 'active'},
133
+ {type: 'status', status: 'connecting'},
134
134
  {type: 'call', call_id: '1', path: '/subs', method: 'post', body: {events: ['message_sent']}},
135
135
  {type: 'wait', timeout: 5000},
136
136
  {type: 'status', status: 'connecting'},
@@ -145,7 +145,7 @@ test.only('realtime', async (t) => {
145
145
  name: 'double subscribe -> do nothing',
146
146
  steps: [
147
147
  {type: 'subscribe', topics: ['message_sent']},
148
- {type: 'status', status: 'active'},
148
+ {type: 'status', status: 'connecting'},
149
149
  {type: 'call', call_id: '1', path: '/subs', method: 'post', body: {events: ['message_sent']}},
150
150
  {type: 'response', call_id: '1', body: {initial_token: 'token1'}, code: 200},
151
151
  {type: 'call', call_id: '2', path: '/poll', query: {token: 'token1'}, method: 'get'},
@@ -157,7 +157,7 @@ test.only('realtime', async (t) => {
157
157
  name: 'polling unstable',
158
158
  steps: [
159
159
  {type: 'subscribe', topics: ['message_sent']},
160
- {type: 'status', status: 'active'},
160
+ {type: 'status', status: 'connecting'},
161
161
  {type: 'call', call_id: '1', path: '/subs', method: 'post', body: {events: ['message_sent']}},
162
162
  {type: 'wait', timeout: 1000},
163
163
  {type: 'response', call_id: '1', body: {initial_token: 'token1'}, code: 200},
@@ -177,7 +177,7 @@ test.only('realtime', async (t) => {
177
177
  name: 'polling dead',
178
178
  steps: [
179
179
  {type: 'subscribe', topics: ['message_sent']},
180
- {type: 'status', status: 'active'},
180
+ {type: 'status', status: 'connecting'},
181
181
  {type: 'call', call_id: '1', path: '/subs', method: 'post', body: {events: ['message_sent']}},
182
182
  {type: 'wait', timeout: 1000},
183
183
  {type: 'response', call_id: '1', body: {initial_token: 'token1'}, code: 200},