Skip to content

Commit

Permalink
feat(ihe): updating dq retries again
Browse files Browse the repository at this point in the history
Refs: #1667
Signed-off-by: Jonah Kaye <[email protected]>
  • Loading branch information
jonahkaye committed Jun 21, 2024
1 parent 7024462 commit d5ecf28
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import axios from "axios";
import * as AWS from "aws-sdk";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { NetworkError } from "@metriport/shared";
import { SamlCertsAndKeys } from "./security/types";
import { Config } from "../../../../util/config";
import { log as getLog, out } from "../../../../util/log";
Expand All @@ -23,6 +24,20 @@ const { log } = out("Saml Client");
const httpTimeoutPatientDiscovery = dayjs.duration({ seconds: 60 });
const httpTimeoutDocumentQuery = dayjs.duration({ seconds: 120 });
const httpTimeoutDocumentRetrieve = dayjs.duration({ seconds: 120 });

const httpCodesToRetry: NetworkError[] = [
"ECONNREFUSED",
"ECONNRESET",
"ETIMEDOUT",
"ECONNABORTED",
];

const httpCodesToRetryPatientDiscovery: NetworkError[] = [...httpCodesToRetry];

const httpCodesToRetryDocumentQuery: NetworkError[] = [...httpCodesToRetry, "ERR_BAD_RESPONSE"];

const httpCodesToRetryDocumentRetrieve: NetworkError[] = [...httpCodesToRetry, "ERR_BAD_RESPONSE"];

const initialDelay = dayjs.duration({ seconds: 3 });
const maxPayloadSize = Infinity;
let rejectUnauthorized = true;
Expand Down Expand Up @@ -102,13 +117,15 @@ export async function sendSignedXml({
"Cache-Control": "no-cache",
},
httpsAgent: agent,
maxBodyLength: maxPayloadSize,
maxContentLength: maxPayloadSize,
});
},
{
initialDelay: initialDelay.asMilliseconds(),
maxAttempts: isDq ? 4 : 3,
//TODO: This introduces retry on timeout without needing to specify the http Code: https://github.com/metriport/metriport/pull/2285. Remove once PR is merged
httpCodesToRetry: ["ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "ECONNABORTED"],
httpCodesToRetry: isDq ? httpCodesToRetryDocumentQuery : httpCodesToRetryPatientDiscovery,
}
);

Expand Down Expand Up @@ -161,13 +178,7 @@ export async function sendSignedXmlMtom({
initialDelay: initialDelay.asMilliseconds(),
maxAttempts: 4,
//TODO: This introduces retry on timeout without needing to specify the http Code: https://github.com/metriport/metriport/pull/2285. Remove once PR is merged
httpCodesToRetry: [
"ECONNREFUSED",
"ECONNRESET",
"ETIMEDOUT",
"ECONNABORTED",
"ERR_BAD_RESPONSE",
],
httpCodesToRetry: httpCodesToRetryDocumentRetrieve,
log: logger,
}
);
Expand Down

0 comments on commit d5ecf28

Please sign in to comment.