Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
improve err handing
Fang-Pen Linc2a33992915f
diff --git a/backend/src/ee/services/pki-acme/pki-acme-challenge-service.ts b/backend/src/ee/services/pki-acme/pki-acme-challenge-service.tsindex a7703f1303..f9be0a60a2 100644--- a/backend/src/ee/services/pki-acme/pki-acme-challenge-service.ts+++ b/backend/src/ee/services/pki-acme/pki-acme-challenge-service.ts@@ -78,18 +78,12 @@ export const pkiAcmeChallengeServiceFactory = ({// Properly type and inspect the errorif (error instanceof TypeError && error.message.includes("fetch failed")) {const cause = error.cause;- if (cause instanceof Error) {- if (cause.message.includes("ECONNREFUSED")) {+ const errors = cause instanceof AggregateError ? cause.errors : cause instanceof Error ? [cause] : [];+ for (const err of errors) {+ // TODO: handle multiple errors, return a compound error instead of just the first error+ if (err?.code === "ECONNREFUSED" || err?.message?.includes("ECONNREFUSED")) {return new AcmeConnectionError({ message: "Connection refused" });- } else if (cause.message.includes("ENOTFOUND")) {- return new AcmeDnsFailureError({ message: "Hostname could not be resolved (DNS failure)" });- }- } else if (cause instanceof AggregateError) {- // TODO: handle multiple errors- const firstError = cause.errors?.[0];- if (firstError?.code === "ECONNREFUSED") {- return new AcmeConnectionError({ message: "Connection refused" });- } else if (firstError?.code === "ENOTFOUND") {+ } else if (err?.code === "ENOTFOUND" || err?.message?.includes("ENOTFOUND")) {return new AcmeDnsFailureError({ message: "Hostname could not be resolved (DNS failure)" });}}