http-request-manager 18.15.9 → 18.15.11
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.
|
@@ -973,7 +973,7 @@ class StreamingProcessor {
|
|
|
973
973
|
return null;
|
|
974
974
|
case HttpEventType.DownloadProgress:
|
|
975
975
|
if (event.partialText) {
|
|
976
|
-
this.
|
|
976
|
+
this.buffer = event.partialText;
|
|
977
977
|
const parsedData = this.parseBuffer();
|
|
978
978
|
// Only return NEW items since last parse (progressive updates)
|
|
979
979
|
const newItems = parsedData.slice(this.lastParsedLength);
|
|
@@ -995,7 +995,7 @@ class StreamingProcessor {
|
|
|
995
995
|
return null;
|
|
996
996
|
case HttpEventType.Response:
|
|
997
997
|
if (event.body) {
|
|
998
|
-
this.
|
|
998
|
+
this.buffer = typeof event.body === 'string' ? event.body : this.buffer;
|
|
999
999
|
const parsedData = this.parseBuffer();
|
|
1000
1000
|
// Calculate final progress
|
|
1001
1001
|
const progress = {
|
|
@@ -1179,10 +1179,12 @@ function parseStreamData(buffer, contentType, config) {
|
|
|
1179
1179
|
*/
|
|
1180
1180
|
function parseNdjson(buffer, config) {
|
|
1181
1181
|
const results = [];
|
|
1182
|
-
const lines = buffer.split('\n')
|
|
1183
|
-
|
|
1182
|
+
const lines = buffer.split('\n');
|
|
1183
|
+
// If the buffer doesn't end with \n, the last segment is an incomplete partial line — skip it
|
|
1184
|
+
const completeLines = buffer.endsWith('\n') ? lines : lines.slice(0, -1);
|
|
1185
|
+
completeLines.filter(line => line.trim()).forEach(line => {
|
|
1184
1186
|
const trimmedLine = line.trim();
|
|
1185
|
-
if (trimmedLine && trimmedLine.startsWith('{')
|
|
1187
|
+
if (trimmedLine && trimmedLine.startsWith('{')) {
|
|
1186
1188
|
const parsed = safeJsonParse(trimmedLine);
|
|
1187
1189
|
if (parsed)
|
|
1188
1190
|
results.push(parsed);
|
|
@@ -1906,6 +1908,7 @@ class WebSocketManagerService {
|
|
|
1906
1908
|
}
|
|
1907
1909
|
// Store jwt token for retry
|
|
1908
1910
|
WebSocketManagerService.lastJwtToken = jwtToken;
|
|
1911
|
+
WebSocketManagerService.lastOptions = options;
|
|
1909
1912
|
WebSocketManagerService.jwtInvalidClose = false;
|
|
1910
1913
|
// Mark as connecting
|
|
1911
1914
|
WebSocketManagerService.isConnecting = true;
|
|
@@ -1925,7 +1928,6 @@ class WebSocketManagerService {
|
|
|
1925
1928
|
WebSocketManagerService.connectionStatus.next(true);
|
|
1926
1929
|
WebSocketManagerService.isConnecting = false;
|
|
1927
1930
|
WebSocketManagerService.connectionInitialized = true;
|
|
1928
|
-
WebSocketManagerService.lastOptions = options;
|
|
1929
1931
|
// Emit reconnect event - MessageTrackerService will handle subscriptions with lastSeenId
|
|
1930
1932
|
console.log(`🔄 Emitting reconnect event for MessageTrackerService`);
|
|
1931
1933
|
WebSocketManagerService.onReconnect.next();
|
|
@@ -1957,7 +1959,7 @@ class WebSocketManagerService {
|
|
|
1957
1959
|
WebSocketManagerService.subscribedChannels.next(new Set());
|
|
1958
1960
|
console.log('✅ subscribedChannels cleared');
|
|
1959
1961
|
if (WebSocketManagerService.jwtInvalidClose) {
|
|
1960
|
-
console.error('🚫 WebSocket closed due to
|
|
1962
|
+
console.error('🚫 WebSocket closed due to authentication block/invalid token. Not retrying.');
|
|
1961
1963
|
WebSocketManagerService.retryCount = 0;
|
|
1962
1964
|
return;
|
|
1963
1965
|
}
|
|
@@ -2954,7 +2956,9 @@ class RequestService extends WebsocketService {
|
|
|
2954
2956
|
observe: 'events',
|
|
2955
2957
|
responseType: 'text',
|
|
2956
2958
|
reportProgress: true
|
|
2957
|
-
}).pipe(
|
|
2959
|
+
}).pipe(
|
|
2960
|
+
// tap(data => console.log('STREAM DATA', data)),
|
|
2961
|
+
requestStreaming({ streamType: options.streamType || StreamType.NDJSON }), this.requestStreaming(options), this.handleFinalize())
|
|
2958
2962
|
: this.http.get(urlPath, headers).pipe(this.request(options));
|
|
2959
2963
|
}
|
|
2960
2964
|
createRecordRequest(options, data) {
|
|
@@ -7754,46 +7758,24 @@ class HTTPManagerStateService extends ComponentStore {
|
|
|
7754
7758
|
else {
|
|
7755
7759
|
this.logger.debug('StateStore', '🔴 WebSocket connection is closed');
|
|
7756
7760
|
}
|
|
7757
|
-
}),
|
|
7761
|
+
}), map(status => {
|
|
7758
7762
|
if (status === true) {
|
|
7759
7763
|
this.shouldRetry = true;
|
|
7760
7764
|
this.wsRetryAttempts.next(0);
|
|
7761
7765
|
this.wsNextRetry.next(0);
|
|
7762
|
-
return
|
|
7763
|
-
}
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
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));
|
|
7766
|
+
return true;
|
|
7767
|
+
}
|
|
7768
|
+
// Retry orchestration is centralized in WebSocketManagerService.connect/onclose
|
|
7769
|
+
// and uses ws.retry from request options. Keep this stream as status/state only.
|
|
7770
|
+
if (!this.shouldRetry) {
|
|
7771
|
+
this.wsRetryAttempts.next(0);
|
|
7772
|
+
this.wsNextRetry.next(0);
|
|
7773
|
+
return false;
|
|
7774
|
+
}
|
|
7775
|
+
const nextAttempt = Math.min(this.wsRetryAttempts.value + 1, this.maxRetries);
|
|
7776
|
+
this.wsRetryAttempts.next(nextAttempt);
|
|
7777
|
+
this.wsNextRetry.next(nextAttempt >= this.maxRetries ? 0 : this.retryDelay / 1000);
|
|
7778
|
+
return false;
|
|
7797
7779
|
}));
|
|
7798
7780
|
}
|
|
7799
7781
|
appendMessages(message) {
|