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(jobs): assembler concurrency within Inngest plan limit

Sidwebworksd236a166dedf
diff --git a/packages/env/src/index.ts b/packages/env/src/index.ts
index e9853c8a4d..ef558a4010 100644
--- a/packages/env/src/index.ts
+++ b/packages/env/src/index.ts
@@ -209,6 +209,14 @@ export const ASSEMBLER_SERVICE_API_KEY = getEnv("ASSEMBLER_SERVICE_API_KEY", {
isRequired: false,
isSecret: true
});
+// Cap on concurrently running assembler-backed Inngest functions (shared across
+// optimize/compact/convert/plan). Must stay within the Inngest plan's account
+// concurrency or app sync fails ("function has higher concurrency limits than
+// your plan"); raise it via env on plans that allow more.
+export const ASSEMBLER_JOB_CONCURRENCY = getEnv("ASSEMBLER_JOB_CONCURRENCY", {
+ isRequired: false,
+ isSecret: false
+});
// Dev-only: public tunnel origin substituted into assembler-bound storage URLs
// when the assembler is remote (local `.dev` hosts resolve only on this
// machine). Unset in prod/preview.
diff --git a/packages/jobs/src/inngest/functions/tasks/assembler-client.ts b/packages/jobs/src/inngest/functions/tasks/assembler-client.ts
index 0c3f86676a..f5dc6337ba 100644
--- a/packages/jobs/src/inngest/functions/tasks/assembler-client.ts
+++ b/packages/jobs/src/inngest/functions/tasks/assembler-client.ts
@@ -1,6 +1,7 @@
import { createHmac } from "node:crypto";
import type { Database, Json } from "@carbon/database";
import {
+ ASSEMBLER_JOB_CONCURRENCY,
ASSEMBLER_SERVICE_API_KEY,
ASSEMBLER_SERVICE_URL,
ASSEMBLER_STORAGE_PUBLIC_URL,
@@ -45,9 +46,19 @@ export const assemblerAuthHeaders: Record<string, string> =
// The cap ≈ how many assembler jobs should run at once (the service 429s past its
// real capacity, so more parked runs buy nothing); the WASM raw tier renders while
// an optimise waits, so a low cap never blocks a user from viewing a model.
+// Default 5: a per-function limit above the Inngest plan's account concurrency
+// fails app sync outright ("function has higher concurrency limits than your
+// plan"), and 5 is the smallest plan cap in play. Override via
+// ASSEMBLER_JOB_CONCURRENCY where the plan allows more.
export const ASSEMBLER_CONCURRENCY: [
{ scope: "env"; key: string; limit: number }
-] = [{ scope: "env", key: '"assembler"', limit: 6 }];
+] = [
+ {
+ scope: "env",
+ key: '"assembler"',
+ limit: Number(ASSEMBLER_JOB_CONCURRENCY) || 5
+ }
+];
/**
* The assembler feature flag IS the config: unset `ASSEMBLER_SERVICE_URL` means