Skip to content

Commit 2bc26c8

Browse files
committed
Fail deployments if creating the background tasks or schedules fails
1 parent 7552e1c commit 2bc26c8

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

apps/webapp/app/v3/services/createDeployedBackgroundWorker.server.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,33 @@ export class CreateDeployedBackgroundWorkerService extends BaseService {
5050
},
5151
});
5252

53-
await createBackgroundTasks(body.metadata.tasks, backgroundWorker, environment, this._prisma);
54-
await syncDeclarativeSchedules(
55-
body.metadata.tasks,
56-
backgroundWorker,
57-
environment,
58-
this._prisma
59-
);
53+
try {
54+
await createBackgroundTasks(
55+
body.metadata.tasks,
56+
backgroundWorker,
57+
environment,
58+
this._prisma
59+
);
60+
await syncDeclarativeSchedules(
61+
body.metadata.tasks,
62+
backgroundWorker,
63+
environment,
64+
this._prisma
65+
);
66+
} catch (error) {
67+
await this._prisma.workerDeployment.update({
68+
where: {
69+
id: deployment.id,
70+
},
71+
data: {
72+
status: "FAILED",
73+
failedAt: new Date(),
74+
errorData: error instanceof Error ? error.message : JSON.stringify(error),
75+
},
76+
});
77+
78+
throw error;
79+
}
6080

6181
// Link the deployment with the background worker
6282
await this._prisma.workerDeployment.update({

0 commit comments

Comments
 (0)