diff --git a/src/graphql/error-map.ts b/src/graphql/error-map.ts index bf3aade1238..b0bb2bc099a 100644 --- a/src/graphql/error-map.ts +++ b/src/graphql/error-map.ts @@ -499,7 +499,8 @@ export const mapError = (error: ApplicationError): CustomApolloError => { case "CouldNotFindLnPaymentFromHashError": case "LockError": case "LockServiceError": - case "ResourceAttemptsLockServiceError": + case "ResourceAttemptsRedlockServiceError": + case "ResourceAttemptsTimelockServiceError": case "ResourceExpiredLockServiceError": case "PriceError": case "PriceServiceError": diff --git a/src/servers/middlewares/idempotency.ts b/src/servers/middlewares/idempotency.ts index d453b6b66c6..e907c002a90 100644 --- a/src/servers/middlewares/idempotency.ts +++ b/src/servers/middlewares/idempotency.ts @@ -70,25 +70,17 @@ export const idempotencyMiddleware = async ( const idempotencyKeyMaybeSuffix = (idempotencyKey + (isPersistedQueryWithExtension ? "-persisted" : "")) as IdempotencyKey - try { - await lockService.lockIdempotencyKey(idempotencyKeyMaybeSuffix) - addAttributesToCurrentSpan({ idempotencyKey }) + const result = await lockService.lockIdempotencyKey(idempotencyKeyMaybeSuffix) + addAttributesToCurrentSpan({ idempotencyKey }) - next() - } catch (error) { - recordExceptionInCurrentSpan({ - error, - fallbackMsg: "Error locking idempotency key", - level: ErrorLevel.Critical, - }) - if (error instanceof ResourceAttemptsTimelockServiceError) { - return res.status(409).json({ error: "the idempotency key already exist" }) - } - if (error instanceof Error) { - return res.status(500).json({ error: error.message }) - } - return res.status(500).json({ error: "Unknown error in idempotency middleware" }) + if (result instanceof ResourceAttemptsTimelockServiceError) { + return res.status(409).json({ error: "the idempotency key already exist" }) } + if (result instanceof Error) { + return res.status(500).json({ error: result.message }) + } + + next() }) } else { next()