Skip to content

Commit a4b25cc

Browse files
committed
Apply timeout on HttpClient
1 parent 453bb88 commit a4b25cc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/httpClient/httpURLConnectionClient.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,15 @@ class HttpURLConnectionClient implements ClientInterface {
118118
requestOptions.headers[ApiConstants.ADYEN_LIBRARY_NAME] = LibraryConstants.LIB_NAME;
119119
requestOptions.headers[ApiConstants.ADYEN_LIBRARY_VERSION] = LibraryConstants.LIB_VERSION;
120120

121-
return httpsRequest(requestOptions);
121+
// create a new ClientRequest object
122+
const req = httpsRequest(requestOptions);
123+
124+
// set the timeout on the ClientRequest instance
125+
if (requestOptions.timeout) {
126+
req.setTimeout(requestOptions.timeout);
127+
}
128+
129+
return req;
122130
}
123131

124132
private getQuery(params: [string, string][]): string {

0 commit comments

Comments
 (0)