Skip to content

Commit b986a2e

Browse files
matt-aitkenjacobparis
authored andcommitted
Don’t start runs if they have runs disabled
1 parent d7240d2 commit b986a2e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

apps/webapp/app/services/runs/startRun.server.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { $transaction, prisma } from "~/db.server";
88
import { workerQueue } from "../worker.server";
99
import { ResumeRunService } from "./resumeRun.server";
1010
import { createHash } from "node:crypto";
11+
import { logger } from "../logger.server";
1112

1213
type FoundRun = NonNullable<Awaited<ReturnType<typeof findRun>>>;
1314
type RunConnectionsByKey = Awaited<ReturnType<typeof createRunConnections>>;
@@ -36,6 +37,13 @@ export class StartRunService {
3637
}
3738

3839
#runIsStartable(run: FoundRun) {
40+
if (!run.organization.runsEnabled) {
41+
logger.debug("StartRunService: Runs are disabled for this organization", {
42+
organizationId: run.organization.id,
43+
});
44+
return false;
45+
}
46+
3947
const startableStatuses = ["PENDING", "WAITING_ON_CONNECTIONS"] as const;
4048
return startableStatuses.includes(run.status);
4149
}
@@ -144,6 +152,7 @@ async function findRun(tx: PrismaClientOrTransaction, id: string) {
144152
include: {
145153
queue: true,
146154
environment: true,
155+
organization: true,
147156
version: {
148157
include: {
149158
integrations: {

0 commit comments

Comments
 (0)