Skip to content

Commit 2fc6e11

Browse files
Bugfix - Enhanced HTTP client module to implement timeouts for failing requests
1 parent c7d8e4c commit 2fc6e11

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
1.17.1 (July 25, 2025)
2+
- Bugfix - Enhanced HTTP client module to implement timeouts for failing requests that might otherwise remain pending indefinitely on some Fetch API implementations, pausing the SDK synchronization process.
3+
14
1.17.0 (September 6, 2024)
25
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
36
- Added `isTimedout` and `lastUpdate` properties to IStatusInterface to keep track of the timestamp of the last SDK event, used on React and Redux SDKs.

src/services/splitHttpClient.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { ERROR_HTTP, ERROR_CLIENT_CANNOT_GET_READY } from '../logger/constants';
44
import { ISettings } from '../types';
55
import { IPlatform } from '../sdkFactory/types';
66
import { decorateHeaders } from './decorateHeaders';
7+
import { timeout } from '../utils/promise/timeout';
78

9+
const PENDING_FETCH_ERROR_TIMEOUT = 100;
810
const messageNoFetch = 'Global fetch API is not available.';
911

1012
/**
@@ -45,7 +47,8 @@ export function splitHttpClientFactory(settings: ISettings, { getOptions, getFet
4547
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Checking_that_the_fetch_was_successful
4648
.then(response => {
4749
if (!response.ok) {
48-
return response.text().then(message => Promise.reject({ response, message }));
50+
// `text()` promise might not settle in some fetch implementations and cases (e.g. no content)
51+
return timeout(PENDING_FETCH_ERROR_TIMEOUT, response.text()).then(message => Promise.reject({ response, message }), () => Promise.reject({ response }));
4952
}
5053
latencyTracker();
5154
return response;

0 commit comments

Comments
 (0)