Skip to content

Commit

Permalink
refactor: invalid token log
Browse files Browse the repository at this point in the history
  • Loading branch information
lsliwaradioluz committed Dec 10, 2024
1 parent db118f5 commit c3ea649
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/api-client/src/helpers/magentoLink/linkHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import { ConfigState } from "../../types/setup";

export const handleRetry =
({ alokai }: { alokai: AlokaiContainer }) =>
(count, operation, error) => {
(retryCount, operation, error) => {
const logger = getLogger(alokai);

if (count > 3) {
if (retryCount > 3) {
return false;
}

if (error?.result?.message === "invalid_token") {
logger.debug(`Apollo retry-link, the operation (${operation.operationName}) sent with wrong token, creating a new one... (attempt: ${count})`);
const { operationName } = operation;
logger.error(`Invalid token used for operation ${operationName}, Apollo retry-link will refresh the token and retry`, {
operation,
retryCount,
});
return true;
}

Expand Down

0 comments on commit c3ea649

Please sign in to comment.