diff --git a/apps/dokploy/__test__/server/mechanizeDockerContainer.test.ts b/apps/dokploy/__test__/server/mechanizeDockerContainer.test.ts index fb448e3af..daf2dbe54 100644 --- a/apps/dokploy/__test__/server/mechanizeDockerContainer.test.ts +++ b/apps/dokploy/__test__/server/mechanizeDockerContainer.test.ts @@ -57,7 +57,7 @@ const createApplication = ( env: null, }, replicas: 1, - stopGracePeriodSwarm: 0n, + stopGracePeriodSwarm: 0, ulimitsSwarm: null, serverId: "server-id", ...overrides, @@ -76,8 +76,8 @@ describe("mechanizeDockerContainer", () => { }); }); - it("converts bigint stopGracePeriodSwarm to a number and keeps zero values", async () => { - const application = createApplication({ stopGracePeriodSwarm: 0n }); + it("passes stopGracePeriodSwarm as a number and keeps zero values", async () => { + const application = createApplication({ stopGracePeriodSwarm: 0 }); await mechanizeDockerContainer(application); diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx index 81a09ec0f..7d214716e 100644 --- a/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/cluster/modify-swarm-settings.tsx @@ -110,6 +110,13 @@ const menuItems: MenuItem[] = [ }, ]; +const hasStopGracePeriodSwarm = ( + value: unknown, +): value is { stopGracePeriodSwarm: number | string | null } => + typeof value === "object" && + value !== null && + "stopGracePeriodSwarm" in value; + interface Props { id: string; type: diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/stop-grace-period-form.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/stop-grace-period-form.tsx index 58b36fbae..ebc93a388 100644 --- a/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/stop-grace-period-form.tsx +++ b/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/stop-grace-period-form.tsx @@ -16,7 +16,7 @@ import { api } from "@/utils/api"; const hasStopGracePeriodSwarm = ( value: unknown, -): value is { stopGracePeriodSwarm: bigint | number | string | null } => +): value is { stopGracePeriodSwarm: number | string | null } => typeof value === "object" && value !== null && "stopGracePeriodSwarm" in value; @@ -68,7 +68,7 @@ export const StopGracePeriodForm = ({ id, type }: StopGracePeriodFormProps) => { const form = useForm({ defaultValues: { - value: null as bigint | null, + value: null as number | null, }, }); @@ -76,11 +76,7 @@ export const StopGracePeriodForm = ({ id, type }: StopGracePeriodFormProps) => { if (hasStopGracePeriodSwarm(data)) { const value = data.stopGracePeriodSwarm; const normalizedValue = - value === null || value === undefined - ? null - : typeof value === "bigint" - ? value - : BigInt(value); + value === null || value === undefined ? null : Number(value); form.reset({ value: normalizedValue, }); @@ -136,7 +132,7 @@ export const StopGracePeriodForm = ({ id, type }: StopGracePeriodFormProps) => { } onChange={(e) => field.onChange( - e.target.value ? BigInt(e.target.value) : null, + e.target.value ? Number(e.target.value) : null, ) } /> diff --git a/apps/dokploy/pages/api/[...trpc].ts b/apps/dokploy/pages/api/[...trpc].ts index 8ee0e9102..83ff9b050 100644 --- a/apps/dokploy/pages/api/[...trpc].ts +++ b/apps/dokploy/pages/api/[...trpc].ts @@ -16,6 +16,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { return createOpenApiNextHandler({ router: appRouter, createContext: createTRPCContext, + onError: + process.env.NODE_ENV === "development" + ? ({ path, error }: { path: string | undefined; error: Error }) => { + console.error( + `❌ OpenAPI failed on ${path ?? ""}: ${error.message}`, + ); + } + : undefined, })(req, res); }; diff --git a/packages/server/src/db/schema/application.ts b/packages/server/src/db/schema/application.ts index c1eb8b65c..a7067f63f 100644 --- a/packages/server/src/db/schema/application.ts +++ b/packages/server/src/db/schema/application.ts @@ -174,7 +174,7 @@ export const applications = pgTable("application", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), - stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "number" }), endpointSpecSwarm: json("endpointSpecSwarm").$type(), ulimitsSwarm: json("ulimitsSwarm").$type(), // @@ -369,7 +369,7 @@ const createSchema = createInsertSchema(applications, { watchPaths: z.array(z.string()).optional().optional(), previewLabels: z.array(z.string()).optional(), cleanCache: z.boolean().optional(), - stopGracePeriodSwarm: z.bigint().nullable(), + stopGracePeriodSwarm: z.number().nullable(), endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), ulimitsSwarm: UlimitsSwarmSchema.nullable(), enableSubmodules: z.boolean().optional(), diff --git a/packages/server/src/db/schema/libsql.ts b/packages/server/src/db/schema/libsql.ts index 0d5e98b78..046f985f7 100644 --- a/packages/server/src/db/schema/libsql.ts +++ b/packages/server/src/db/schema/libsql.ts @@ -79,7 +79,7 @@ export const libsql = pgTable("libsql", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), - stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "number" }), endpointSpecSwarm: json("endpointSpecSwarm").$type(), replicas: integer("replicas").default(1).notNull(), createdAt: text("createdAt") @@ -143,7 +143,7 @@ const createSchema = createInsertSchema(libsql, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), - stopGracePeriodSwarm: z.bigint().nullable(), + stopGracePeriodSwarm: z.number().nullable(), endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), }); diff --git a/packages/server/src/db/schema/mariadb.ts b/packages/server/src/db/schema/mariadb.ts index 0b58fcf54..ce3f3e2d2 100644 --- a/packages/server/src/db/schema/mariadb.ts +++ b/packages/server/src/db/schema/mariadb.ts @@ -73,7 +73,7 @@ export const mariadb = pgTable("mariadb", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), - stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "number" }), endpointSpecSwarm: json("endpointSpecSwarm").$type(), ulimitsSwarm: json("ulimitsSwarm").$type(), replicas: integer("replicas").default(1).notNull(), @@ -144,7 +144,7 @@ const createSchema = createInsertSchema(mariadb, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), - stopGracePeriodSwarm: z.bigint().nullable(), + stopGracePeriodSwarm: z.number().nullable(), endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), ulimitsSwarm: UlimitsSwarmSchema.nullable(), }); diff --git a/packages/server/src/db/schema/mongo.ts b/packages/server/src/db/schema/mongo.ts index 6a70918c4..a5910f197 100644 --- a/packages/server/src/db/schema/mongo.ts +++ b/packages/server/src/db/schema/mongo.ts @@ -76,7 +76,7 @@ export const mongo = pgTable("mongo", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), - stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "number" }), endpointSpecSwarm: json("endpointSpecSwarm").$type(), ulimitsSwarm: json("ulimitsSwarm").$type(), replicas: integer("replicas").default(1).notNull(), @@ -142,7 +142,7 @@ const createSchema = createInsertSchema(mongo, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), - stopGracePeriodSwarm: z.bigint().nullable(), + stopGracePeriodSwarm: z.number().nullable(), endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), ulimitsSwarm: UlimitsSwarmSchema.nullable(), }); diff --git a/packages/server/src/db/schema/mysql.ts b/packages/server/src/db/schema/mysql.ts index b555214f3..a9a5d072f 100644 --- a/packages/server/src/db/schema/mysql.ts +++ b/packages/server/src/db/schema/mysql.ts @@ -71,7 +71,7 @@ export const mysql = pgTable("mysql", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), - stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "number" }), endpointSpecSwarm: json("endpointSpecSwarm").$type(), ulimitsSwarm: json("ulimitsSwarm").$type(), replicas: integer("replicas").default(1).notNull(), @@ -141,7 +141,7 @@ const createSchema = createInsertSchema(mysql, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), - stopGracePeriodSwarm: z.bigint().nullable(), + stopGracePeriodSwarm: z.number().nullable(), endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), ulimitsSwarm: UlimitsSwarmSchema.nullable(), }); diff --git a/packages/server/src/db/schema/postgres.ts b/packages/server/src/db/schema/postgres.ts index 8f96caa92..954b15d4a 100644 --- a/packages/server/src/db/schema/postgres.ts +++ b/packages/server/src/db/schema/postgres.ts @@ -71,7 +71,7 @@ export const postgres = pgTable("postgres", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), - stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "number" }), endpointSpecSwarm: json("endpointSpecSwarm").$type(), ulimitsSwarm: json("ulimitsSwarm").$type(), replicas: integer("replicas").default(1).notNull(), @@ -136,7 +136,7 @@ const createSchema = createInsertSchema(postgres, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), - stopGracePeriodSwarm: z.bigint().nullable(), + stopGracePeriodSwarm: z.number().nullable(), endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), ulimitsSwarm: UlimitsSwarmSchema.nullable(), }); diff --git a/packages/server/src/db/schema/redis.ts b/packages/server/src/db/schema/redis.ts index f02437805..c07074d0c 100644 --- a/packages/server/src/db/schema/redis.ts +++ b/packages/server/src/db/schema/redis.ts @@ -64,7 +64,7 @@ export const redis = pgTable("redis", { modeSwarm: json("modeSwarm").$type(), labelsSwarm: json("labelsSwarm").$type(), networkSwarm: json("networkSwarm").$type(), - stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "bigint" }), + stopGracePeriodSwarm: bigint("stopGracePeriodSwarm", { mode: "number" }), endpointSpecSwarm: json("endpointSpecSwarm").$type(), ulimitsSwarm: json("ulimitsSwarm").$type(), replicas: integer("replicas").default(1).notNull(), @@ -121,7 +121,7 @@ const createSchema = createInsertSchema(redis, { modeSwarm: ServiceModeSwarmSchema.nullable(), labelsSwarm: LabelsSwarmSchema.nullable(), networkSwarm: NetworkSwarmSchema.nullable(), - stopGracePeriodSwarm: z.bigint().nullable(), + stopGracePeriodSwarm: z.number().nullable(), endpointSpecSwarm: EndpointSpecSwarmSchema.nullable(), ulimitsSwarm: UlimitsSwarmSchema.nullable(), }); diff --git a/packages/server/src/utils/docker/utils.ts b/packages/server/src/utils/docker/utils.ts index 75068696e..17804dcc0 100644 --- a/packages/server/src/utils/docker/utils.ts +++ b/packages/server/src/utils/docker/utils.ts @@ -554,11 +554,6 @@ export const generateConfigContainer = ( ulimitsSwarm, } = application; - const sanitizedStopGracePeriodSwarm = - typeof stopGracePeriodSwarm === "bigint" - ? Number(stopGracePeriodSwarm) - : stopGracePeriodSwarm; - const haveMounts = mounts && mounts.length > 0; return { @@ -605,9 +600,9 @@ export const generateConfigContainer = ( Order: "start-first", }, }), - ...(sanitizedStopGracePeriodSwarm !== null && - sanitizedStopGracePeriodSwarm !== undefined && { - StopGracePeriod: sanitizedStopGracePeriodSwarm, + ...(stopGracePeriodSwarm !== null && + stopGracePeriodSwarm !== undefined && { + StopGracePeriod: stopGracePeriodSwarm, }), ...(networkSwarm ? {