Skip to content

Commit 01633c9

Browse files
committed
Print error logs on dev worker failure
1 parent 691990d commit 01633c9

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.changeset/plenty-ducks-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Output stderr logs on dev worker failure

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ function useDev({
670670
const parsedError = parseNpmInstallError(e);
671671

672672
if (typeof parsedError === "string") {
673-
logger.log(`${chalkError("X Error:")} ${parsedError}`);
673+
logger.log(`\n${chalkError("X Error:")} ${parsedError}`);
674674
} else {
675675
switch (parsedError.type) {
676676
case "package-not-found-error": {
@@ -693,6 +693,15 @@ function useDev({
693693
}
694694
}
695695
}
696+
697+
const stderr = backgroundWorker.stderr
698+
.map((line) => line.trim())
699+
.filter((line) => line.length > 0)
700+
.join("\n");
701+
702+
if (stderr) {
703+
logger.log(`\n${chalkError("X Error logs:")}\n${stderr}`);
704+
}
696705
}
697706
});
698707
},

packages/cli-v3/src/workers/dev/backgroundWorker.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export class BackgroundWorker {
279279

280280
public tasks: Array<TaskMetadataWithFilePath> = [];
281281
public metadata: BackgroundWorkerProperties | undefined;
282+
public stderr: Array<string> = [];
282283

283284
_taskRunProcesses: Map<string, TaskRunProcess> = new Map();
284285
private _taskRunProcessesBeingKilled: Set<number> = new Set();
@@ -406,6 +407,10 @@ export class BackgroundWorker {
406407
child.stdout?.on("data", (data) => {
407408
logger.log(data.toString());
408409
});
410+
411+
child.stderr?.on("data", (data) => {
412+
this.stderr.push(data.toString());
413+
});
409414
});
410415

411416
this._initialized = true;

0 commit comments

Comments
 (0)