Skip to content

Commit e962187

Browse files
Merge pull request #4329 from NativeScript/milanov/retry-only-get-requests
fix: uploading big files with the $httpClient
2 parents 3298880 + e34cf27 commit e962187

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/common/http-client.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ export class HttpClient implements Server.IHttpClient {
133133
const requestObj = request(options);
134134
cleanupRequestData.req = requestObj;
135135

136-
stuckRequestTimerId = setTimeout(() => {
137-
clearTimeout(stuckRequestTimerId);
138-
stuckRequestTimerId = null;
139-
if (!hasResponse) {
140-
this.setResponseResult(promiseActions, cleanupRequestData, { err: new Error(HttpClient.STUCK_REQUEST_ERROR_MESSAGE) });
141-
}
142-
}, options.timeout || HttpClient.STUCK_REQUEST_TIMEOUT);
143-
cleanupRequestData.timers.push(stuckRequestTimerId);
136+
if (options.method !== "PUT" && options.method !== "POST") {
137+
stuckRequestTimerId = setTimeout(() => {
138+
clearTimeout(stuckRequestTimerId);
139+
stuckRequestTimerId = null;
140+
if (!hasResponse) {
141+
this.setResponseResult(promiseActions, cleanupRequestData, { err: new Error(HttpClient.STUCK_REQUEST_ERROR_MESSAGE) });
142+
}
143+
}, options.timeout || HttpClient.STUCK_REQUEST_TIMEOUT);
144+
cleanupRequestData.timers.push(stuckRequestTimerId);
145+
}
144146

145147
requestObj
146148
.on("error", (err: IHttpRequestError) => {

0 commit comments

Comments
 (0)