http-request-manager 18.15.8 → 18.15.10

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.
@@ -1906,6 +1906,7 @@ class WebSocketManagerService {
1906
1906
  }
1907
1907
  // Store jwt token for retry
1908
1908
  WebSocketManagerService.lastJwtToken = jwtToken;
1909
+ WebSocketManagerService.lastOptions = options;
1909
1910
  WebSocketManagerService.jwtInvalidClose = false;
1910
1911
  // Mark as connecting
1911
1912
  WebSocketManagerService.isConnecting = true;
@@ -1925,7 +1926,6 @@ class WebSocketManagerService {
1925
1926
  WebSocketManagerService.connectionStatus.next(true);
1926
1927
  WebSocketManagerService.isConnecting = false;
1927
1928
  WebSocketManagerService.connectionInitialized = true;
1928
- WebSocketManagerService.lastOptions = options;
1929
1929
  // Emit reconnect event - MessageTrackerService will handle subscriptions with lastSeenId
1930
1930
  console.log(`🔄 Emitting reconnect event for MessageTrackerService`);
1931
1931
  WebSocketManagerService.onReconnect.next();
@@ -1957,7 +1957,7 @@ class WebSocketManagerService {
1957
1957
  WebSocketManagerService.subscribedChannels.next(new Set());
1958
1958
  console.log('✅ subscribedChannels cleared');
1959
1959
  if (WebSocketManagerService.jwtInvalidClose) {
1960
- console.error('🚫 WebSocket closed due to JWT_INVALID. Not retrying.');
1960
+ console.error('🚫 WebSocket closed due to authentication block/invalid token. Not retrying.');
1961
1961
  WebSocketManagerService.retryCount = 0;
1962
1962
  return;
1963
1963
  }
@@ -6887,7 +6887,7 @@ class HTTPManagerStateService extends ComponentStore {
6887
6887
  console.log('Received:', message);
6888
6888
  // Debug: Log all message types
6889
6889
  this.logger.debug('StateStore', '📨 Message type', { type: message.type });
6890
- if (message.error === 'JWT_INVALID') {
6890
+ if (message.error === 'JWT_INVALID' || message.error === 'AUTH_BLOCKED') {
6891
6891
  this.shouldRetry = false;
6892
6892
  this.httpManagerService.disconnect();
6893
6893
  }
@@ -7754,46 +7754,24 @@ class HTTPManagerStateService extends ComponentStore {
7754
7754
  else {
7755
7755
  this.logger.debug('StateStore', '🔴 WebSocket connection is closed');
7756
7756
  }
7757
- }), switchMap(status => {
7757
+ }), map(status => {
7758
7758
  if (status === true) {
7759
7759
  this.shouldRetry = true;
7760
7760
  this.wsRetryAttempts.next(0);
7761
7761
  this.wsNextRetry.next(0);
7762
- return of(true);
7763
- }
7764
- if (!this.shouldRetry)
7765
- return of(false);
7766
- const countdownEnder$ = new Subject();
7767
- // Immediately reflect upcoming retry delay in seconds on UI
7768
- const seconds = this.retryDelay / 1000;
7769
- this.wsNextRetry.next(seconds);
7770
- return timer(0, this.retryDelay)
7771
- .pipe(take(this.maxRetries), tap(i => {
7772
- const attempt = i + 1;
7773
- this.wsRetryAttempts.next(attempt);
7774
- countdownEnder$.next();
7775
- // Validate WS options; abort retries if invalid
7776
- const hasValidWS = !!(this.apiOptions.ws && this.apiOptions.ws.wsServer && this.apiOptions.ws.wsServer !== '');
7777
- if (!hasValidWS) {
7778
- this.shouldRetry = false;
7779
- this.wsNextRetry.next(0);
7780
- this.wsRetryAttempts.next(0);
7781
- return; // Skip connect and countdown
7782
- }
7783
- console.log(`🔄 Retry attempt #${attempt}/${this.maxRetries}`);
7784
- this.httpManagerService.connect(this.apiOptions.ws, this.apiOptions.ws.jwtToken || '');
7785
- if (attempt === this.maxRetries) {
7786
- this.wsNextRetry.next(0);
7787
- // console.error(`🚨 FAILED CONNECTION: Tried #${attempt} times`);
7788
- }
7789
- else {
7790
- // console.log(`⚠️ Retry Attempt #${attempt}: Retrying in ${this.retryDelay / 1000}s`);
7791
- const seconds = this.retryDelay / 1000;
7792
- timer(0, 1000).pipe(map(tick => seconds - tick), takeWhile(val => val >= 0), takeUntil(countdownEnder$)).subscribe(remaining => {
7793
- this.wsNextRetry.next(remaining);
7794
- });
7795
- }
7796
- }), map(() => false));
7762
+ return true;
7763
+ }
7764
+ // Retry orchestration is centralized in WebSocketManagerService.connect/onclose
7765
+ // and uses ws.retry from request options. Keep this stream as status/state only.
7766
+ if (!this.shouldRetry) {
7767
+ this.wsRetryAttempts.next(0);
7768
+ this.wsNextRetry.next(0);
7769
+ return false;
7770
+ }
7771
+ const nextAttempt = Math.min(this.wsRetryAttempts.value + 1, this.maxRetries);
7772
+ this.wsRetryAttempts.next(nextAttempt);
7773
+ this.wsNextRetry.next(nextAttempt >= this.maxRetries ? 0 : this.retryDelay / 1000);
7774
+ return false;
7797
7775
  }));
7798
7776
  }
7799
7777
  appendMessages(message) {