Skip to content

Commit

Permalink
Merge pull request #2298 from metriport/fix-dr-lambda-duration=dq-tim…
Browse files Browse the repository at this point in the history
…eouts

fix(ihev2): bump dr lambda duration, bump attempt up on dq retries
  • Loading branch information
jonahkaye committed Jun 19, 2024
2 parents 0447f9d + ab63f8b commit c8e18aa
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ describe("processDrResponse", () => {
expect(response.documentReference?.length).toBe(2);
expect(response?.documentReference?.[0]?.contentType).toEqual("application/octet-stream");
expect(response?.documentReference?.[0]?.docUniqueId).toEqual("123456789");
expect(response?.documentReference?.[0]?.homeCommunityId).toEqual("2.16.840.1.113883.3.8391");
expect(response?.documentReference?.[0]?.homeCommunityId).toEqual("2.16.840.1.113883.3.9621");
expect(response?.documentReference?.[0]?.repositoryUniqueId).toEqual(
"urn:oid:2.16.840.1.113883.3.9621"
);

expect(response?.documentReference?.[1]?.contentType).toEqual("application/octet-stream");
expect(response?.documentReference?.[1]?.docUniqueId).toEqual("987654321");
expect(response?.documentReference?.[1]?.homeCommunityId).toEqual("2.16.840.1.113883.3.8391");
expect(response?.documentReference?.[1]?.homeCommunityId).toEqual("2.16.840.1.113883.3.9621");
expect(response?.documentReference?.[1]?.repositoryUniqueId).toEqual(
"urn:oid:2.16.840.1.113883.3.9621"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
<ihe:RetrieveDocumentSetResponse xmlns:ihe="urn:ihe:iti:xds-b:2007">
<RegistryResponse xmlns="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0" status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success"/>
<DocumentResponse>
<HomeCommunityId>urn:oid:urn:oid:2.16.840.1.113883.3.9621</HomeCommunityId>
<HomeCommunityId>urn:oid:2.16.840.1.113883.3.9621</HomeCommunityId>
<RepositoryUniqueId>urn:oid:2.16.840.1.113883.3.9621</RepositoryUniqueId>
<DocumentUniqueId>123456789</DocumentUniqueId>
<mimeType>application/pdf</mimeType>
<Document>Metriport Rocks!</Document>
</DocumentResponse>
<DocumentResponse>
<HomeCommunityId>urn:oid:urn:oid:2.16.840.1.113883.3.9621</HomeCommunityId>
<HomeCommunityId>urn:oid:2.16.840.1.113883.3.9621</HomeCommunityId>
<RepositoryUniqueId>urn:oid:2.16.840.1.113883.3.9621</RepositoryUniqueId>
<DocumentUniqueId>987654321</DocumentUniqueId>
<mimeType>application/xml</mimeType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async function processDocumentReference({
docUniqueId: documentResponse.DocumentUniqueId.toString(),
metriportId: metriportId,
fileLocation: bucket,
homeCommunityId: outboundRequest.gateway.homeCommunityId,
homeCommunityId: stripUrnPrefix(documentResponse.HomeCommunityId),
repositoryUniqueId: documentResponse.RepositoryUniqueId,
newDocumentUniqueId: documentResponse.NewDocumentUniqueId,
newRepositoryUniqueId: documentResponse.NewRepositoryUniqueId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function sendSignedDqRequest({
signedXml: request.signedRequest,
url: request.gateway.url,
samlCertsAndKeys,
isDq: true,
});
log(
`Request ${index + 1} sent successfully to: ${request.gateway.url} + oid: ${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function sendSignedXCPDRequests({
signedXml: request.signedRequest,
url: request.gateway.url,
samlCertsAndKeys,
isDq: false,
});
log(
`Request ${index + 1} sent successfully to: ${request.gateway.url} + oid: ${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export async function sendSignedXml({
signedXml,
url,
samlCertsAndKeys,
isDq,
}: {
signedXml: string;
url: string;
samlCertsAndKeys: SamlCertsAndKeys;
isDq: boolean;
}): Promise<{ response: string; contentType: string }> {
const trustedKeyStore = await getTrustedKeyStore();
const agent = new https.Agent({
Expand Down Expand Up @@ -100,9 +102,9 @@ export async function sendSignedXml({
},
{
initialDelay: initialDelay.asMilliseconds(),
maxAttempts: 3,
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"],
httpCodesToRetry: ["ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "ECONNABORTED"],
}
);

Expand Down
2 changes: 1 addition & 1 deletion packages/infra/lib/ihe-gateway-v2-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class IHEGatewayV2LambdasNestedStack extends NestedStack {
},
layers: [lambdaLayers.shared],
memory: 1024,
timeout: Duration.minutes(5),
timeout: Duration.minutes(15),
vpc,
});

Expand Down

0 comments on commit c8e18aa

Please sign in to comment.