Skip to content

Commit 9a3e8d0

Browse files
author
Deploy Bot
committed
Merge branch 'fix/issue-2909-orphaned-workers'
2 parents 82f198f + c97cbcc commit 9a3e8d0

20 files changed

+1625
-77
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
Fix: ConsoleInterceptor now delegates to original console methods to preserve log chain when other interceptors (like Sentry) are present. (#2900)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/cli-v3": patch
3+
---
4+
5+
Fix: Native build server failed with Docker Hub rate limits. Added support for checking checking `DOCKER_USERNAME` and `DOCKER_PASSWORD` in environment variables and logging into Docker Hub before building. (#2911)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/cli-v3": patch
3+
---
4+
5+
Fix: Ignore engine checks during deployment install phase to prevent failure on build server when Node version mismatch exists. (#2913)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/cli-v3": patch
3+
---
4+
5+
Fix: `trigger.dev dev` command left orphaned worker processes when exited via Ctrl+C (SIGINT). Added signal handlers to ensure proper cleanup of child processes and lockfiles. (#2909)

packages/cli-v3/src/commands/deploy.ts

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
252252
}
253253

254254
if (!options.skipUpdateCheck) {
255-
await updateTriggerPackages(dir, { ...options }, true, true);
255+
await updateTriggerPackages(dir, { ...options, ignoreEngines: true }, true, true);
256256
}
257257

258258
const cwd = process.cwd();
@@ -489,9 +489,8 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
489489
const version = deployment.version;
490490

491491
const rawDeploymentLink = `${authorization.dashboardUrl}/projects/v3/${resolvedConfig.project}/deployments/${deployment.shortCode}`;
492-
const rawTestLink = `${authorization.dashboardUrl}/projects/v3/${
493-
resolvedConfig.project
494-
}/test?environment=${options.env === "prod" ? "prod" : "stg"}`;
492+
const rawTestLink = `${authorization.dashboardUrl}/projects/v3/${resolvedConfig.project
493+
}/test?environment=${options.env === "prod" ? "prod" : "stg"}`;
495494

496495
const deploymentLink = cliLink("View deployment", rawDeploymentLink);
497496
const testLink = cliLink("Test tasks", rawTestLink);
@@ -708,8 +707,7 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
708707
}
709708
} else {
710709
outro(
711-
`Version ${version} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${
712-
isLinksSupported ? `| ${deploymentLink} | ${testLink}` : ""
710+
`Version ${version} deployed with ${taskCount} detected task${taskCount === 1 ? "" : "s"} ${isLinksSupported ? `| ${deploymentLink} | ${testLink}` : ""
713711
}`
714712
);
715713

@@ -733,18 +731,16 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) {
733731
TRIGGER_VERSION: version,
734732
TRIGGER_DEPLOYMENT_SHORT_CODE: deployment.shortCode,
735733
TRIGGER_DEPLOYMENT_URL: `${authorization.dashboardUrl}/projects/v3/${resolvedConfig.project}/deployments/${deployment.shortCode}`,
736-
TRIGGER_TEST_URL: `${authorization.dashboardUrl}/projects/v3/${
737-
resolvedConfig.project
738-
}/test?environment=${options.env === "prod" ? "prod" : "stg"}`,
734+
TRIGGER_TEST_URL: `${authorization.dashboardUrl}/projects/v3/${resolvedConfig.project
735+
}/test?environment=${options.env === "prod" ? "prod" : "stg"}`,
739736
},
740737
outputs: {
741738
deploymentVersion: version,
742739
workerVersion: version,
743740
deploymentShortCode: deployment.shortCode,
744741
deploymentUrl: `${authorization.dashboardUrl}/projects/v3/${resolvedConfig.project}/deployments/${deployment.shortCode}`,
745-
testUrl: `${authorization.dashboardUrl}/projects/v3/${
746-
resolvedConfig.project
747-
}/test?environment=${options.env === "prod" ? "prod" : "stg"}`,
742+
testUrl: `${authorization.dashboardUrl}/projects/v3/${resolvedConfig.project
743+
}/test?environment=${options.env === "prod" ? "prod" : "stg"}`,
748744
needsPromotion: options.skipPromotion ? "true" : "false",
749745
},
750746
});
@@ -787,8 +783,7 @@ async function failDeploy(
787783
checkLogsForErrors(logs);
788784

789785
outro(
790-
`${chalkError(`${prefix}:`)} ${
791-
error.message
786+
`${chalkError(`${prefix}:`)} ${error.message
792787
}. Full build logs have been saved to ${logPath}`
793788
);
794789

@@ -1088,9 +1083,8 @@ async function handleNativeBuildServerDeploy({
10881083
const deployment = initializeDeploymentResult.data;
10891084

10901085
const rawDeploymentLink = `${dashboardUrl}/projects/v3/${config.project}/deployments/${deployment.shortCode}`;
1091-
const rawTestLink = `${dashboardUrl}/projects/v3/${config.project}/test?environment=${
1092-
options.env === "prod" ? "prod" : "stg"
1093-
}`;
1086+
const rawTestLink = `${dashboardUrl}/projects/v3/${config.project}/test?environment=${options.env === "prod" ? "prod" : "stg"
1087+
}`;
10941088

10951089
const exposedDeploymentLink = isLinksSupported
10961090
? cliLink(chalk.bold(rawDeploymentLink), rawDeploymentLink)
@@ -1156,8 +1150,7 @@ async function handleNativeBuildServerDeploy({
11561150
log.warn(`Failed streaming build logs, open the deployment in the dashboard to view the logs`);
11571151

11581152
outro(
1159-
`Version ${deployment.version} is being deployed ${
1160-
isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
1153+
`Version ${deployment.version} is being deployed ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
11611154
}`
11621155
);
11631156

@@ -1204,10 +1197,10 @@ async function handleNativeBuildServerDeploy({
12041197
level === "error"
12051198
? chalk.bold(chalkError(message))
12061199
: level === "warn"
1207-
? chalkWarning(message)
1208-
: level === "debug"
1209-
? chalkGrey(message)
1210-
: message;
1200+
? chalkWarning(message)
1201+
: level === "debug"
1202+
? chalkGrey(message)
1203+
: message;
12111204

12121205
// We use console.log here instead of clack's logger as the current version does not support changing the line spacing.
12131206
// And the logs look verbose with the default spacing.
@@ -1240,8 +1233,7 @@ async function handleNativeBuildServerDeploy({
12401233
log.error("Failed dequeueing build, please try again shortly");
12411234

12421235
throw new OutroCommandError(
1243-
`Version ${deployment.version} ${
1244-
isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
1236+
`Version ${deployment.version} ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
12451237
}`
12461238
);
12471239
}
@@ -1256,8 +1248,7 @@ async function handleNativeBuildServerDeploy({
12561248
}
12571249

12581250
throw new OutroCommandError(
1259-
`Version ${deployment.version} ${
1260-
isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
1251+
`Version ${deployment.version} ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
12611252
}`
12621253
);
12631254
}
@@ -1283,13 +1274,12 @@ async function handleNativeBuildServerDeploy({
12831274
}
12841275

12851276
outro(
1286-
`Version ${deployment.version} was deployed ${
1287-
isLinksSupported
1288-
? `| ${cliLink("Test tasks", rawTestLink)} | ${cliLink(
1289-
"View deployment",
1290-
rawDeploymentLink
1291-
)}`
1292-
: ""
1277+
`Version ${deployment.version} was deployed ${isLinksSupported
1278+
? `| ${cliLink("Test tasks", rawTestLink)} | ${cliLink(
1279+
"View deployment",
1280+
rawDeploymentLink
1281+
)}`
1282+
: ""
12931283
}`
12941284
);
12951285
return process.exit(0);
@@ -1303,14 +1293,13 @@ async function handleNativeBuildServerDeploy({
13031293
chalk.bold(
13041294
chalkError(
13051295
"Deployment failed" +
1306-
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : "")
1296+
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : "")
13071297
)
13081298
)
13091299
);
13101300

13111301
throw new OutroCommandError(
1312-
`Version ${deployment.version} deployment failed ${
1313-
isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
1302+
`Version ${deployment.version} deployment failed ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
13141303
}`
13151304
);
13161305
}
@@ -1323,14 +1312,13 @@ async function handleNativeBuildServerDeploy({
13231312
chalk.bold(
13241313
chalkError(
13251314
"Deployment timed out" +
1326-
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : "")
1315+
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : "")
13271316
)
13281317
)
13291318
);
13301319

13311320
throw new OutroCommandError(
1332-
`Version ${deployment.version} deployment timed out ${
1333-
isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
1321+
`Version ${deployment.version} deployment timed out ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
13341322
}`
13351323
);
13361324
}
@@ -1343,14 +1331,13 @@ async function handleNativeBuildServerDeploy({
13431331
chalk.bold(
13441332
chalkError(
13451333
"Deployment was canceled" +
1346-
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : "")
1334+
(finalDeploymentEvent.message ? `: ${finalDeploymentEvent.message}` : "")
13471335
)
13481336
)
13491337
);
13501338

13511339
throw new OutroCommandError(
1352-
`Version ${deployment.version} deployment canceled ${
1353-
isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
1340+
`Version ${deployment.version} deployment canceled ${isLinksSupported ? `| ${cliLink("View deployment", rawDeploymentLink)}` : ""
13541341
}`
13551342
);
13561343
}
@@ -1369,13 +1356,12 @@ async function handleNativeBuildServerDeploy({
13691356
}
13701357

13711358
outro(
1372-
`Version ${deployment.version} ${
1373-
isLinksSupported
1374-
? `| ${cliLink("Test tasks", rawTestLink)} | ${cliLink(
1375-
"View deployment",
1376-
rawDeploymentLink
1377-
)}`
1378-
: ""
1359+
`Version ${deployment.version} ${isLinksSupported
1360+
? `| ${cliLink("Test tasks", rawTestLink)} | ${cliLink(
1361+
"View deployment",
1362+
rawDeploymentLink
1363+
)}`
1364+
: ""
13791365
}`
13801366
);
13811367
return process.exit(0);

packages/cli-v3/src/commands/dev.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,38 @@ export async function devCommand(options: DevCommandOptions) {
171171
);
172172
} else {
173173
logger.log(
174-
`${chalkError("X Error:")} You must login first. Use the \`login\` CLI command.\n\n${
175-
authorization.error
174+
`${chalkError("X Error:")} You must login first. Use the \`login\` CLI command.\n\n${authorization.error
176175
}`
177176
);
178177
}
179178
process.exitCode = 1;
180179
return;
181180
}
182181

183-
let watcher;
182+
let devInstance: Awaited<ReturnType<typeof startDev>> | undefined;
183+
184+
const cleanup = async () => {
185+
if (devInstance) {
186+
await devInstance.stop();
187+
}
188+
};
189+
190+
const signalHandler = async (signal: string) => {
191+
logger.debug(`Received ${signal}, cleaning up...`);
192+
await cleanup();
193+
process.exit(0);
194+
};
195+
184196
try {
185-
const devInstance = await startDev({ ...options, cwd: process.cwd(), login: authorization });
186-
watcher = devInstance.watcher;
197+
process.on("SIGINT", signalHandler);
198+
process.on("SIGTERM", signalHandler);
199+
200+
devInstance = await startDev({ ...options, cwd: process.cwd(), login: authorization });
187201
await devInstance.waitUntilExit();
188202
} finally {
189-
await watcher?.stop();
203+
process.off("SIGINT", signalHandler);
204+
process.off("SIGTERM", signalHandler);
205+
await cleanup();
190206
}
191207
}
192208

@@ -272,7 +288,7 @@ async function startDev(options: StartDevOptions) {
272288

273289
devInstance = await bootDevSession(watcher.config);
274290

275-
const waitUntilExit = async () => {};
291+
const waitUntilExit = async () => { };
276292

277293
return {
278294
watcher,

0 commit comments

Comments
 (0)