Skip to content

Commit 58b0f61

Browse files
committed
fix(webapp): consistent deployment.outcome attributes (env on bgworker-fail; drop unused CANCELED)
1 parent ff69578 commit 58b0f61

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
112112
if (findOrCreateError instanceof ServiceValidationError) {
113113
// `#failBackgroundWorkerDeployment` already throws its argument; the
114114
// outer `throw` covers the non-SVE branch.
115-
await this.#failBackgroundWorkerDeployment(deployment, findOrCreateError);
115+
await this.#failBackgroundWorkerDeployment(deployment, findOrCreateError, environment);
116116
}
117117
throw findOrCreateError;
118118
}
@@ -145,7 +145,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
145145

146146
const serviceError = new ServiceValidationError("Error creating background worker files");
147147

148-
await this.#failBackgroundWorkerDeployment(deployment, serviceError);
148+
await this.#failBackgroundWorkerDeployment(deployment, serviceError, environment);
149149

150150
throw serviceError;
151151
}
@@ -168,7 +168,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
168168
error: resourcesError.message,
169169
});
170170

171-
await this.#failBackgroundWorkerDeployment(deployment, resourcesError);
171+
await this.#failBackgroundWorkerDeployment(deployment, resourcesError, environment);
172172
throw resourcesError;
173173
}
174174

@@ -180,7 +180,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
180180
"Error creating background worker resources"
181181
);
182182

183-
await this.#failBackgroundWorkerDeployment(deployment, serviceError);
183+
await this.#failBackgroundWorkerDeployment(deployment, serviceError, environment);
184184

185185
throw serviceError;
186186
}
@@ -207,7 +207,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
207207
error: schedulesError.message,
208208
});
209209

210-
await this.#failBackgroundWorkerDeployment(deployment, schedulesError);
210+
await this.#failBackgroundWorkerDeployment(deployment, schedulesError, environment);
211211
throw schedulesError;
212212
}
213213

@@ -221,7 +221,7 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
221221

222222
const serviceError = new ServiceValidationError("Error syncing declarative schedules");
223223

224-
await this.#failBackgroundWorkerDeployment(deployment, serviceError);
224+
await this.#failBackgroundWorkerDeployment(deployment, serviceError, environment);
225225

226226
throw serviceError;
227227
}
@@ -265,7 +265,11 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
265265
});
266266
}
267267

268-
async #failBackgroundWorkerDeployment(deployment: WorkerDeployment, error: Error) {
268+
async #failBackgroundWorkerDeployment(
269+
deployment: WorkerDeployment,
270+
error: Error,
271+
environment: AuthenticatedEnvironment
272+
) {
269273
// Guarded BUILDING → FAILED transition, symmetric with the BUILDING → DEPLOYING
270274
// transition in `call()`. With idempotent retries, two attempts can run side-by-side;
271275
// without the predicate, one attempt's failure could downgrade the deployment after
@@ -302,8 +306,10 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
302306
recordDeploymentOutcome({
303307
status: "FAILED",
304308
deploymentFriendlyId: deployment.friendlyId,
305-
projectId: deployment.projectId,
306-
environmentId: deployment.environmentId,
309+
organizationId: environment.organizationId,
310+
projectId: environment.projectId,
311+
environmentId: environment.id,
312+
environmentType: environment.type,
307313
reason: error.message,
308314
});
309315
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { tracer } from "~/v3/tracer.server";
55

66
type TerminalDeploymentStatus = Extract<
77
WorkerDeploymentStatus,
8-
"DEPLOYED" | "FAILED" | "TIMED_OUT" | "CANCELED"
8+
"DEPLOYED" | "FAILED" | "TIMED_OUT"
99
>;
1010

1111
/**

0 commit comments

Comments
 (0)