Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: stricter resend error handling

Sidwebworks98d1ad2f74e0
diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx
index 7986d3f445..e468b472c2 100644
--- a/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx
+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.send.tsx
@@ -178,7 +178,9 @@ export async function action(args: ActionFunctionArgs) {
const emailSignature = `Thanks,\n${user.data.firstName} ${user.data.lastName}\n${company.data.name}`;
await trigger("send-email-resend", {
- to: [user.data.email, supplierContact.data.contact?.email ?? ""],
+ to: [user.data.email, supplierContact.data.contact?.email].filter(
+ Boolean
+ ) as string[],
cc: ccSelections?.length ? ccSelections : undefined,
from: user.data.email,
subject: emailSubject,
diff --git a/packages/jobs/src/inngest/functions/notifications/send-email.ts b/packages/jobs/src/inngest/functions/notifications/send-email.ts
index 037b507e5d..51688f2d1b 100644
--- a/packages/jobs/src/inngest/functions/notifications/send-email.ts
+++ b/packages/jobs/src/inngest/functions/notifications/send-email.ts
@@ -1,5 +1,6 @@
import { getCarbonServiceRole } from "@carbon/auth/client.server";
import { Resend as ResendConfig } from "@carbon/ee";
+import { NonRetriableError, serializeError } from "inngest";
import { Resend } from "resend";
import { inngest } from "../../client";
@@ -61,7 +62,16 @@ export const sendEmailFunction = inngest.createFunction(
};
console.info(`Resend Email Job`);
- return resend.emails.send(email);
+ const response = await resend.emails.send(email);
+ if (response.error) {
+ if (response.error.name === "validation_error") {
+ throw new NonRetriableError(
+ `Resend validation error: ${serializeError(response.error)}`
+ );
+ }
+ throw new Error(`Resend error: ${serializeError(response.error)}`);
+ }
+ return response.data;
});
return { success: true, result };