@itentialopensource/adapter-utils 6.1.9 → 6.1.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.
- package/lib/connectorRest.js +9 -6
- package/package.json +1 -1
package/lib/connectorRest.js
CHANGED
|
@@ -913,11 +913,12 @@ function makeRequest(request, entitySchema, callProperties, startTrip, attempt,
|
|
|
913
913
|
};
|
|
914
914
|
let didTimeout = 0;
|
|
915
915
|
|
|
916
|
-
|
|
917
|
-
|
|
916
|
+
if (cerror.code === 'ETIMEDOUT') {
|
|
917
|
+
callResp.code = -2;
|
|
918
|
+
didTimeout += 1;
|
|
919
|
+
} else if (cerror.code === 'ECONNRESET') {
|
|
920
|
+
// Connection reset - check if it was our timeout
|
|
918
921
|
const endTime = new Date().getTime();
|
|
919
|
-
|
|
920
|
-
// see if this is a client timeout
|
|
921
922
|
if (endTime - stTime >= myTimeout) {
|
|
922
923
|
callResp.code = -2;
|
|
923
924
|
didTimeout += 1;
|
|
@@ -938,8 +939,10 @@ function makeRequest(request, entitySchema, callProperties, startTrip, attempt,
|
|
|
938
939
|
});
|
|
939
940
|
|
|
940
941
|
httpRequest.setTimeout(myTimeout, () => {
|
|
941
|
-
|
|
942
|
-
|
|
942
|
+
const timeoutError = new Error('Request timeout');
|
|
943
|
+
timeoutError.code = 'ETIMEDOUT';
|
|
944
|
+
httpRequest.destroy(timeoutError);
|
|
945
|
+
});
|
|
943
946
|
|
|
944
947
|
// write to the http request data to the body if not a get (gets do not have data in the body)
|
|
945
948
|
if ((request.header.method !== 'GET' || entitySchema.sendGetBody)
|