5ba8557a51
## Summary v3 (the engine that ran the SDK v3 era, internally `RunEngineVersion.V1`) is end-of-life. Following the removal of the v3 execution apps ([#4194](https://github.com/triggerdotdev/trigger.dev/pull/4194)) and the legacy dev websocket ([#4198](https://github.com/triggerdotdev/trigger.dev/pull/4198)), this removes the remaining v3 execution stack from the server. Clients still on v3 (an old SDK or CLI that has not upgraded) keep getting a clear "upgrade to v4" response. Triggers, batch triggers, reschedules, and deploys that resolve to v3 are rejected with a graceful 4xx pointing at the migration guide, never a 5xx, so a stale client cannot affect server health. Self-hosted instances still running v3 should stay on the 4.5.x release line until they migrate. ## What is removed - The MarQS queue and its shared/dev queue consumers. - The v3 socket.io namespaces (coordinator, provider, shared-queue) and the v3 run lifecycle services (attempt, checkpoint, and batch-resume). - The graphile-worker background job system; all live jobs already run on `@trigger.dev/redis-worker`. - The `DEPRECATE_V3_ENABLED` flag: v3 is now rejected unconditionally, so the flag is gone. - Unused v3 exports from `@trigger.dev/core` (the `v3/zodNamespace` subpath and the legacy socket message catalogs) and the now-dead MarQS environment variables. ## What stays The v4 engine is untouched. The graceful v3 rejection boundary stays, `determineEngineVersion` still detects a v3 project so it can reject it, and the batch service plus batch-completion worker stay for current clients. Live queue concurrency limits and metrics now read from the v4 run engine instead of MarQS, and a brand-new dev environment now defaults to v4. ## Dependency cleanup Removes webapp dependencies left unused by this change: `seedrandom` and `semver` (only the removed v3 code used them) plus a set that was already dead, their orphaned `@types` packages, and two dead files. Adds a `knip:deps` script and a `knip.json` config so unused dependencies can be found the same way going forward.
84 lines
2.2 KiB
TypeScript
84 lines
2.2 KiB
TypeScript
import type { PrismaClient } from "@trigger.dev/database";
|
|
import { prisma } from "~/db.server";
|
|
import { engine } from "~/v3/runEngine.server";
|
|
import { controlPlaneResolver } from "~/v3/runOpsMigration/controlPlaneResolver.server";
|
|
|
|
type Options = ({ projectId: string } | { projectSlug: string }) & {
|
|
userId: string;
|
|
};
|
|
|
|
export class DeleteProjectService {
|
|
#prismaClient: PrismaClient;
|
|
|
|
constructor(prismaClient: PrismaClient = prisma) {
|
|
this.#prismaClient = prismaClient;
|
|
}
|
|
|
|
public async call(options: Options) {
|
|
const projectId = await this.#getProjectId(options);
|
|
const project = await this.#prismaClient.project.findFirst({
|
|
include: {
|
|
environments: true,
|
|
organization: true,
|
|
},
|
|
where: {
|
|
id: projectId,
|
|
organization: { members: { some: { userId: options.userId } } },
|
|
},
|
|
});
|
|
|
|
if (!project) {
|
|
throw new Error("Project not found");
|
|
}
|
|
|
|
if (project.deletedAt) {
|
|
return;
|
|
}
|
|
|
|
// Delete all queues from the RunEngine 2 prod master queues
|
|
for (const environment of project.environments) {
|
|
await engine.removeEnvironmentQueuesFromMasterQueue({
|
|
runtimeEnvironmentId: environment.id,
|
|
organizationId: project.organization.id,
|
|
projectId: project.id,
|
|
});
|
|
}
|
|
|
|
// Soft delete only: run-ops rows are intentionally retained (no hard-delete cascade here).
|
|
|
|
// Mark the project as deleted (do this last because it makes it impossible to try again)
|
|
// - This disables all API keys
|
|
// - This disables all schedules from being scheduled
|
|
await this.#prismaClient.project.update({
|
|
where: {
|
|
id: project.id,
|
|
},
|
|
data: {
|
|
deletedAt: new Date(),
|
|
},
|
|
});
|
|
|
|
// project.deletedAt (which gates env resolution) changed; drop every cached env of this project.
|
|
for (const environment of project.environments) {
|
|
controlPlaneResolver.invalidateEnvironment(environment.id);
|
|
}
|
|
}
|
|
|
|
async #getProjectId(options: Options) {
|
|
if ("projectId" in options) {
|
|
return options.projectId;
|
|
}
|
|
|
|
const { id } = await this.#prismaClient.project.findFirstOrThrow({
|
|
select: {
|
|
id: true,
|
|
},
|
|
where: {
|
|
slug: options.projectSlug,
|
|
},
|
|
});
|
|
|
|
return id;
|
|
}
|
|
}
|