genesys-cloud-streaming-client 17.2.3-develop.106 → 17.2.3

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.
@@ -48,6 +48,7 @@ export declare class Client extends EventEmitter {
48
48
  private handleNoLongerSubscribed;
49
49
  private handleDuplicateId;
50
50
  disconnect(): Promise<any>;
51
+ private getSessionStoreKey;
51
52
  private getConnectionData;
52
53
  private setConnectionData;
53
54
  private increaseBackoff;
@@ -224,8 +224,12 @@ class Client extends events_1.default {
224
224
  .then(resolve);
225
225
  }, 5000, 'disconnecting streaming service');
226
226
  }
227
+ getSessionStoreKey() {
228
+ const differentiator = this.config.appName || this.logger.clientId;
229
+ return `${SESSION_STORE_KEY}_${differentiator}`;
230
+ }
227
231
  getConnectionData() {
228
- const connectionDataStr = sessionStorage.getItem(SESSION_STORE_KEY);
232
+ const connectionDataStr = sessionStorage.getItem(this.getSessionStoreKey());
229
233
  const defaultValue = {
230
234
  currentDelayMs: 0,
231
235
  };
@@ -241,17 +245,19 @@ class Client extends events_1.default {
241
245
  return defaultValue;
242
246
  }
243
247
  setConnectionData(data) {
244
- sessionStorage.setItem(SESSION_STORE_KEY, JSON.stringify(data));
248
+ sessionStorage.setItem(this.getSessionStoreKey(), JSON.stringify(data));
245
249
  }
246
250
  increaseBackoff() {
247
251
  const connectionData = this.getConnectionData();
248
- const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY);
249
- this.setConnectionData({
252
+ const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY * 2);
253
+ const newConnectionData = {
250
254
  currentDelayMs: currentDelay,
251
255
  delayMsAfterNextReduction: currentDelay / 2,
252
256
  nextDelayReductionTime: new Date().getTime() + (currentDelay * BACKOFF_DECREASE_DELAY_MULTIPLIER),
253
257
  timeOfTotalReset: new Date().getTime() + 1000 * 60 * 60 // one hour in the future
254
- });
258
+ };
259
+ this.setConnectionData(newConnectionData);
260
+ return newConnectionData;
255
261
  }
256
262
  decreaseBackoff(newAmountMs) {
257
263
  const data = this.getConnectionData();
@@ -301,6 +307,9 @@ class Client extends events_1.default {
301
307
  const startingDelay = this.getStartingDelay(connectionData, maxDelay);
302
308
  const delayFirstAttempt = this.hasMadeInitialAttempt;
303
309
  this.hasMadeInitialAttempt = true;
310
+ if (connectionData.currentDelayMs) {
311
+ this.logger.debug('streamingClient.connect was called, but backoff is remembered', { currentDelayMs: connectionData.currentDelayMs, delayingThisAttempt: delayFirstAttempt, clientId: this.logger.clientId, appName: this.config.appName });
312
+ }
304
313
  try {
305
314
  await exponential_backoff_1.backOff(async () => {
306
315
  const connectionData = this.getConnectionData();
@@ -407,8 +416,9 @@ class Client extends events_1.default {
407
416
  return true;
408
417
  }
409
418
  }
419
+ const connectionData = this.increaseBackoff();
410
420
  this.logger.error('Failed streaming client connection attempt, retrying', additionalErrorDetails, { skipServer: err instanceof offline_error_1.default });
411
- this.increaseBackoff();
421
+ this.logger.debug('debug: retry info', { expectedRetryInMs: connectionData.currentDelayMs, appName: this.config.appName, clientId: this.logger.clientId });
412
422
  return true;
413
423
  }
414
424
  async makeConnectionAttempt() {
@@ -17,6 +17,6 @@
17
17
  "file": "v17/streaming-client.browser.js"
18
18
  }
19
19
  ],
20
- "build": "106",
21
- "buildDate": "2024-06-27T23:18:38.267203Z"
20
+ "build": "99",
21
+ "buildDate": "2024-07-25T19:27:48.060772690Z"
22
22
  }
@@ -48,6 +48,7 @@ export declare class Client extends EventEmitter {
48
48
  private handleNoLongerSubscribed;
49
49
  private handleDuplicateId;
50
50
  disconnect(): Promise<any>;
51
+ private getSessionStoreKey;
51
52
  private getConnectionData;
52
53
  private setConnectionData;
53
54
  private increaseBackoff;
package/dist/es/client.js CHANGED
@@ -226,8 +226,12 @@ export class Client extends EventEmitter {
226
226
  }, 5000, 'disconnecting streaming service');
227
227
  });
228
228
  }
229
+ getSessionStoreKey() {
230
+ const differentiator = this.config.appName || this.logger.clientId;
231
+ return `${SESSION_STORE_KEY}_${differentiator}`;
232
+ }
229
233
  getConnectionData() {
230
- const connectionDataStr = sessionStorage.getItem(SESSION_STORE_KEY);
234
+ const connectionDataStr = sessionStorage.getItem(this.getSessionStoreKey());
231
235
  const defaultValue = {
232
236
  currentDelayMs: 0,
233
237
  };
@@ -243,17 +247,19 @@ export class Client extends EventEmitter {
243
247
  return defaultValue;
244
248
  }
245
249
  setConnectionData(data) {
246
- sessionStorage.setItem(SESSION_STORE_KEY, JSON.stringify(data));
250
+ sessionStorage.setItem(this.getSessionStoreKey(), JSON.stringify(data));
247
251
  }
248
252
  increaseBackoff() {
249
253
  const connectionData = this.getConnectionData();
250
- const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY);
251
- this.setConnectionData({
254
+ const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY * 2);
255
+ const newConnectionData = {
252
256
  currentDelayMs: currentDelay,
253
257
  delayMsAfterNextReduction: currentDelay / 2,
254
258
  nextDelayReductionTime: new Date().getTime() + (currentDelay * BACKOFF_DECREASE_DELAY_MULTIPLIER),
255
259
  timeOfTotalReset: new Date().getTime() + 1000 * 60 * 60 // one hour in the future
256
- });
260
+ };
261
+ this.setConnectionData(newConnectionData);
262
+ return newConnectionData;
257
263
  }
258
264
  decreaseBackoff(newAmountMs) {
259
265
  const data = this.getConnectionData();
@@ -304,6 +310,9 @@ export class Client extends EventEmitter {
304
310
  const startingDelay = this.getStartingDelay(connectionData, maxDelay);
305
311
  const delayFirstAttempt = this.hasMadeInitialAttempt;
306
312
  this.hasMadeInitialAttempt = true;
313
+ if (connectionData.currentDelayMs) {
314
+ this.logger.debug('streamingClient.connect was called, but backoff is remembered', { currentDelayMs: connectionData.currentDelayMs, delayingThisAttempt: delayFirstAttempt, clientId: this.logger.clientId, appName: this.config.appName });
315
+ }
307
316
  try {
308
317
  yield backOff(() => __awaiter(this, void 0, void 0, function* () {
309
318
  const connectionData = this.getConnectionData();
@@ -412,8 +421,9 @@ export class Client extends EventEmitter {
412
421
  return true;
413
422
  }
414
423
  }
424
+ const connectionData = this.increaseBackoff();
415
425
  this.logger.error('Failed streaming client connection attempt, retrying', additionalErrorDetails, { skipServer: err instanceof OfflineError });
416
- this.increaseBackoff();
426
+ this.logger.debug('debug: retry info', { expectedRetryInMs: connectionData.currentDelayMs, appName: this.config.appName, clientId: this.logger.clientId });
417
427
  return true;
418
428
  });
419
429
  }
@@ -41707,8 +41707,12 @@ class Client extends EventEmitter {
41707
41707
  }, 5000, 'disconnecting streaming service');
41708
41708
  });
41709
41709
  }
41710
+ getSessionStoreKey() {
41711
+ const differentiator = this.config.appName || this.logger.clientId;
41712
+ return `${SESSION_STORE_KEY}_${differentiator}`;
41713
+ }
41710
41714
  getConnectionData() {
41711
- const connectionDataStr = sessionStorage.getItem(SESSION_STORE_KEY);
41715
+ const connectionDataStr = sessionStorage.getItem(this.getSessionStoreKey());
41712
41716
  const defaultValue = {
41713
41717
  currentDelayMs: 0,
41714
41718
  };
@@ -41724,17 +41728,19 @@ class Client extends EventEmitter {
41724
41728
  return defaultValue;
41725
41729
  }
41726
41730
  setConnectionData(data) {
41727
- sessionStorage.setItem(SESSION_STORE_KEY, JSON.stringify(data));
41731
+ sessionStorage.setItem(this.getSessionStoreKey(), JSON.stringify(data));
41728
41732
  }
41729
41733
  increaseBackoff() {
41730
41734
  const connectionData = this.getConnectionData();
41731
- const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY);
41732
- this.setConnectionData({
41735
+ const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY * 2);
41736
+ const newConnectionData = {
41733
41737
  currentDelayMs: currentDelay,
41734
41738
  delayMsAfterNextReduction: currentDelay / 2,
41735
41739
  nextDelayReductionTime: new Date().getTime() + (currentDelay * BACKOFF_DECREASE_DELAY_MULTIPLIER),
41736
41740
  timeOfTotalReset: new Date().getTime() + 1000 * 60 * 60 // one hour in the future
41737
- });
41741
+ };
41742
+ this.setConnectionData(newConnectionData);
41743
+ return newConnectionData;
41738
41744
  }
41739
41745
  decreaseBackoff(newAmountMs) {
41740
41746
  const data = this.getConnectionData();
@@ -41785,6 +41791,9 @@ class Client extends EventEmitter {
41785
41791
  const startingDelay = this.getStartingDelay(connectionData, maxDelay);
41786
41792
  const delayFirstAttempt = this.hasMadeInitialAttempt;
41787
41793
  this.hasMadeInitialAttempt = true;
41794
+ if (connectionData.currentDelayMs) {
41795
+ this.logger.debug('streamingClient.connect was called, but backoff is remembered', { currentDelayMs: connectionData.currentDelayMs, delayingThisAttempt: delayFirstAttempt, clientId: this.logger.clientId, appName: this.config.appName });
41796
+ }
41788
41797
  try {
41789
41798
  yield backOff_1(() => __awaiter$5(this, void 0, void 0, function* () {
41790
41799
  const connectionData = this.getConnectionData();
@@ -41893,8 +41902,9 @@ class Client extends EventEmitter {
41893
41902
  return true;
41894
41903
  }
41895
41904
  }
41905
+ const connectionData = this.increaseBackoff();
41896
41906
  this.logger.error('Failed streaming client connection attempt, retrying', additionalErrorDetails, { skipServer: err instanceof OfflineError });
41897
- this.increaseBackoff();
41907
+ this.logger.debug('debug: retry info', { expectedRetryInMs: connectionData.currentDelayMs, appName: this.config.appName, clientId: this.logger.clientId });
41898
41908
  return true;
41899
41909
  });
41900
41910
  }
@@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- # [Unreleased](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v17.2.2...HEAD)
7
+ # [Unreleased](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v17.2.3...HEAD)
8
+ # [v17.2.3](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v17.2.2...v17.2.3)
9
+ ### Fixed
10
+ * [STREAM-134](https://inindca.atlassian.net/browse/STREAM-134) Isolate streaming client backoff delays by app name
8
11
  ### Changed
9
12
  * [no-jira] Fix string interpolation for log message and update docs for `useServerSidePings` default
10
13
 
@@ -48,6 +48,7 @@ export declare class Client extends EventEmitter {
48
48
  private handleNoLongerSubscribed;
49
49
  private handleDuplicateId;
50
50
  disconnect(): Promise<any>;
51
+ private getSessionStoreKey;
51
52
  private getConnectionData;
52
53
  private setConnectionData;
53
54
  private increaseBackoff;
@@ -224,8 +224,12 @@ class Client extends events_1.default {
224
224
  .then(resolve);
225
225
  }, 5000, 'disconnecting streaming service');
226
226
  }
227
+ getSessionStoreKey() {
228
+ const differentiator = this.config.appName || this.logger.clientId;
229
+ return `${SESSION_STORE_KEY}_${differentiator}`;
230
+ }
227
231
  getConnectionData() {
228
- const connectionDataStr = sessionStorage.getItem(SESSION_STORE_KEY);
232
+ const connectionDataStr = sessionStorage.getItem(this.getSessionStoreKey());
229
233
  const defaultValue = {
230
234
  currentDelayMs: 0,
231
235
  };
@@ -241,17 +245,19 @@ class Client extends events_1.default {
241
245
  return defaultValue;
242
246
  }
243
247
  setConnectionData(data) {
244
- sessionStorage.setItem(SESSION_STORE_KEY, JSON.stringify(data));
248
+ sessionStorage.setItem(this.getSessionStoreKey(), JSON.stringify(data));
245
249
  }
246
250
  increaseBackoff() {
247
251
  const connectionData = this.getConnectionData();
248
- const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY);
249
- this.setConnectionData({
252
+ const currentDelay = Math.max(connectionData.currentDelayMs * 2, INITIAL_DELAY * 2);
253
+ const newConnectionData = {
250
254
  currentDelayMs: currentDelay,
251
255
  delayMsAfterNextReduction: currentDelay / 2,
252
256
  nextDelayReductionTime: new Date().getTime() + (currentDelay * BACKOFF_DECREASE_DELAY_MULTIPLIER),
253
257
  timeOfTotalReset: new Date().getTime() + 1000 * 60 * 60 // one hour in the future
254
- });
258
+ };
259
+ this.setConnectionData(newConnectionData);
260
+ return newConnectionData;
255
261
  }
256
262
  decreaseBackoff(newAmountMs) {
257
263
  const data = this.getConnectionData();
@@ -301,6 +307,9 @@ class Client extends events_1.default {
301
307
  const startingDelay = this.getStartingDelay(connectionData, maxDelay);
302
308
  const delayFirstAttempt = this.hasMadeInitialAttempt;
303
309
  this.hasMadeInitialAttempt = true;
310
+ if (connectionData.currentDelayMs) {
311
+ this.logger.debug('streamingClient.connect was called, but backoff is remembered', { currentDelayMs: connectionData.currentDelayMs, delayingThisAttempt: delayFirstAttempt, clientId: this.logger.clientId, appName: this.config.appName });
312
+ }
304
313
  try {
305
314
  await exponential_backoff_1.backOff(async () => {
306
315
  const connectionData = this.getConnectionData();
@@ -407,8 +416,9 @@ class Client extends events_1.default {
407
416
  return true;
408
417
  }
409
418
  }
419
+ const connectionData = this.increaseBackoff();
410
420
  this.logger.error('Failed streaming client connection attempt, retrying', additionalErrorDetails, { skipServer: err instanceof offline_error_1.default });
411
- this.increaseBackoff();
421
+ this.logger.debug('debug: retry info', { expectedRetryInMs: connectionData.currentDelayMs, appName: this.config.appName, clientId: this.logger.clientId });
412
422
  return true;
413
423
  }
414
424
  async makeConnectionAttempt() {