Skip to content

Commit 3e19ccf

Browse files
committed
Merge branch 'main' into graphile-upgrade
2 parents 32dd68f + c644912 commit 3e19ccf

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

apps/webapp/app/services/events/ingestSendEvent.server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export class IngestSendEvent {
6060
try {
6161
const deliverAt = this.#calculateDeliverAt(options);
6262

63+
if (!environment.organization.runsEnabled) {
64+
logger.debug("IngestSendEvent: Runs are disabled for this organization", environment);
65+
return;
66+
}
67+
6368
return await $transaction(this.#prismaClient, async (tx) => {
6469
const externalAccount = options?.accountId
6570
? await tx.externalAccount.upsert({

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: {

apps/webapp/app/services/sources/handleHttpSource.server.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { workerQueue } from "../worker.server";
44
import { requestUrl } from "~/utils/requestUrl.server";
55
import { RuntimeEnvironmentType } from "@trigger.dev/database";
66
import { createHttpSourceRequest } from "~/utils/createHttpSourceRequest";
7+
import { logger } from "../logger.server";
78

89
export class HandleHttpSourceService {
910
#prismaClient: PrismaClient;
@@ -19,6 +20,7 @@ export class HandleHttpSourceService {
1920
endpoint: true,
2021
environment: true,
2122
secretReference: true,
23+
organization: true,
2224
},
2325
});
2426

@@ -30,6 +32,13 @@ export class HandleHttpSourceService {
3032
return { status: 200 };
3133
}
3234

35+
if (!triggerSource.organization.runsEnabled) {
36+
logger.debug("HandleHttpSourceService: Runs are disabled for this organization", {
37+
organizationId: triggerSource.organization.id,
38+
});
39+
return { status: 404 };
40+
}
41+
3342
if (!triggerSource.interactive) {
3443
const sourceRequest = await createHttpSourceRequest(request);
3544

0 commit comments

Comments
 (0)