Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATCH Retries ihev2 #2291

Merged
merged 5 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(ihev2): increasing dr retries count + adding bad response retry
Refs: #1667
Signed-off-by: Jonah Kaye <[email protected]>
  • Loading branch information
jonahkaye committed Jun 18, 2024
commit 2ac2825a02164a873e1c3eda9bbe505284b2a8e9
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
OutboundDocumentQueryReq,
OutboundDocumentRetrievalReq,
} from "@metriport/ihe-gateway-sdk";
import { sleep } from "@metriport/shared";
import { makeLambdaClient } from "../../aws/lambda";
import { Config } from "../../../util/config";
import { processAsyncError } from "../../../util/error/shared";
Expand Down Expand Up @@ -108,9 +109,14 @@ export class IHEGatewayV2Async extends IHEGatewayV2 {
MAX_DOCUMENT_RETRIEVAL_REQUESTS_PER_INVOCATION
);

for (const chunk of requestChunks) {
for (let i = 0; i < requestChunks.length; i++) {
const chunk = requestChunks[i];
jonahkaye marked this conversation as resolved.
Show resolved Hide resolved
const params = { patientId, cxId, requestId, drRequestsGatewayV2: chunk };

if (i > 0) {
await sleep(1000);
jonahkaye marked this conversation as resolved.
Show resolved Hide resolved
}

// intentionally not waiting
lambdaClient
.invoke({
Expand Down
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was missing these from previous PR

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function handleHttpErrorResponse({
gateway,
patientId: outboundRequest?.patientId,
patientMatch: null,
iheGatewayV2: true,
operationOutcome,
};
}
Expand Down Expand Up @@ -74,6 +75,7 @@ export function handlePatientErrorResponse({
gateway,
patientId: outboundRequest.patientId,
patientMatch: null,
iheGatewayV2: true,
operationOutcome,
};
return response;
Expand Down Expand Up @@ -108,6 +110,7 @@ export function handleSchemaErrorResponse({
gateway,
patientId: outboundRequest.patientId,
patientMatch: null,
iheGatewayV2: true,
operationOutcome,
};
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,21 @@ export async function sendSignedXmlMtom({
},
httpsAgent: agent,
responseType: "arraybuffer",
maxBodyLength: Infinity,
maxContentLength: Infinity,
Copy link
Member Author

@jonahkaye jonahkaye Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxContentLength size of -1 exceeded
^ we have had this error in prod 3 times

We added retries for ERR_BAD_RESPONSE, and this change was also recommended in this issue

axios/axios#1362

});
},
{
initialDelay: 3000,
jonahkaye marked this conversation as resolved.
Show resolved Hide resolved
maxAttempts: 3,
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"],
httpCodesToRetry: [
"ECONNREFUSED",
"ECONNRESET",
"ETIMEDOUT",
"ECONNABORTED",
"ERR_BAD_RESPONSE",
],
}
);

Expand Down
4 changes: 3 additions & 1 deletion packages/shared/src/net/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { AxiosError } from "axios";
// https://nodejs.org/docs/latest-v18.x/api/errors.html#common-system-errors
export type NodeNetworkError = "ECONNREFUSED" | "ECONNRESET";

export type NodeResponseError = "ERR_BAD_RESPONSE";
leite08 marked this conversation as resolved.
Show resolved Hide resolved

export type AxiosNetworkError = typeof AxiosError.ETIMEDOUT | typeof AxiosError.ECONNABORTED;

export type NetworkError = NodeNetworkError | AxiosNetworkError;
export type NetworkError = NodeNetworkError | AxiosNetworkError | NodeResponseError;
Loading