Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .server-changes/retire-legacy-v3-dev-websocket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
area: webapp
type: breaking
---

Removed support for the end-of-life v3 `trigger dev` CLI. Starting a dev session with an old v3 CLI now returns an upgrade message instead of connecting - upgrade to the v4 CLI to continue using `trigger dev`.
181 changes: 0 additions & 181 deletions apps/webapp/app/v3/authenticatedSocketConnection.server.ts

This file was deleted.

57 changes: 10 additions & 47 deletions apps/webapp/app/v3/handleWebsockets.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,15 @@ import { WebSocketServer, type WebSocket } from "ws";
import { authenticateApiKey } from "~/services/apiAuth.server";
import { logger } from "~/services/logger.server";
import { singleton } from "../utils/singleton";
import { AuthenticatedSocketConnection } from "./authenticatedSocketConnection.server";
import { Gauge } from "prom-client";
import { metricsRegister } from "~/metrics.server";
import { isV3Disabled, V3_DEV_DEPRECATION_MESSAGE } from "./engineDeprecation.server";
import { V3_DEV_DEPRECATION_MESSAGE } from "./engineDeprecation.server";

export const wss = singleton("wss", initalizeWebSocketServer);

let authenticatedConnections: Map<string, AuthenticatedSocketConnection>;

function initalizeWebSocketServer() {
const server = new WebSocketServer({ noServer: true });

server.on("connection", handleWebSocketConnection);

authenticatedConnections = new Map();

new Gauge({
name: "dev_authenticated_connections",
help: "Number of authenticated dev connections",
collect() {
this.set(authenticatedConnections.size);
},
registers: [metricsRegister],
});

return server;
Comment thread
nicktrn marked this conversation as resolved.
}

Expand Down Expand Up @@ -59,35 +43,14 @@ async function handleWebSocketConnection(ws: WebSocket, req: IncomingMessage) {

const authenticatedEnv = authenticationResult.environment;

// This legacy websocket is only used by the v3 `trigger dev` CLI (v4 uses a
// different dev transport). When the v3 shutdown is on, close it with a
// graceful reason instead of letting the CLI sit connected with no work.
if (isV3Disabled()) {
logger.warn("Rejected deprecated v3 dev CLI websocket connection", {
environmentId: authenticatedEnv.id,
projectId: authenticatedEnv.projectId,
organizationId: authenticatedEnv.organizationId,
});
ws.close(1008, V3_DEV_DEPRECATION_MESSAGE);
return;
}

const authenticatedConnection = new AuthenticatedSocketConnection(
ws,
authenticatedEnv,
req.headers["x-forwarded-for"] ?? req.socket.remoteAddress ?? "unknown"
);

authenticatedConnections.set(authenticatedConnection.id, authenticatedConnection);

authenticatedConnection.onClose.attachOnce((closeEvent) => {
logger.debug("Websocket closed", {
closeEvent,
authenticatedConnectionId: authenticatedConnection.id,
});

authenticatedConnections.delete(authenticatedConnection.id);
// This websocket is only used by the legacy v3 `trigger dev` CLI (v4 uses a
// different dev transport). The v3 engine is end-of-lifed, so there is no
// longer any work to run here — close with the graceful upgrade message so
// an old CLI is told what to do instead of sitting connected.
logger.warn("Rejected deprecated v3 dev CLI websocket connection", {
environmentId: authenticatedEnv.id,
projectId: authenticatedEnv.projectId,
organizationId: authenticatedEnv.organizationId,
});

await authenticatedConnection.initialize();
ws.close(1008, V3_DEV_DEPRECATION_MESSAGE);
Comment thread
nicktrn marked this conversation as resolved.
Comment thread
nicktrn marked this conversation as resolved.
Comment thread
nicktrn marked this conversation as resolved.
}
9 changes: 6 additions & 3 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@
{
"group": "Environment variables",
"pages": ["self-hosting/env/webapp", "self-hosting/env/supervisor"]
},
"open-source-self-hosting"
}
]
},
{
Expand Down Expand Up @@ -735,9 +734,13 @@
"source": "/v3/upgrading-from-v2",
"destination": "/guides/use-cases/upgrading-from-v2"
},
{
"source": "/open-source-self-hosting",
"destination": "/self-hosting/overview"
},
{
"source": "/v3/open-source-self-hosting",
"destination": "/open-source-self-hosting"
"destination": "/self-hosting/overview"
},
{
"source": "/v3/:slug*",
Expand Down
2 changes: 1 addition & 1 deletion docs/github-repo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ url: "https://github.com/triggerdotdev/trigger.dev"

Trigger.dev is [Open Source on GitHub](https://github.com/triggerdotdev/trigger.dev). You can contribute to the project by submitting issues, pull requests, or simply by using it and providing feedback.

You can also [self-host](/open-source-self-hosting) the project if you want to run it on your own infrastructure.
You can also [self-host](/self-hosting/overview) the project if you want to run it on your own infrastructure.
Loading