Skip to content

Commit 92969e2

Browse files
committed
fix(webapp): drop dead !backgroundWorker guard, comment unreachable throw
Both nits surfaced by a local code review of the previous commit: - `findOrCreateBackgroundWorker` returns `Promise<BackgroundWorker>` (non-null). After `if (findOrCreateError) throw`, TypeScript narrows `backgroundWorker` to `BackgroundWorker` already, so the guard was dead code. Worse, returning silently there would have been a 200 with no body — strictly worse than the 5xx the rest of the file produces on internal errors. - Annotate that `#failBackgroundWorkerDeployment` throws its own argument, so the outer `throw findOrCreateError` is only reachable on the non-SVE branch. Same control flow, less confusing for future readers.
1 parent d6e4a0f commit 92969e2

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ export class CreateDeploymentBackgroundWorkerServiceV4 extends BaseService {
109109
// immediately instead of waiting 8 minutes for the timeout. Transient
110110
// races throw a plain `Error` and propagate as 5xx without failing.
111111
if (findOrCreateError instanceof ServiceValidationError) {
112+
// `#failBackgroundWorkerDeployment` already throws its argument; the
113+
// outer `throw` covers the non-SVE branch.
112114
await this.#failBackgroundWorkerDeployment(deployment, findOrCreateError);
113115
}
114116
throw findOrCreateError;
115117
}
116118

117-
if (!backgroundWorker) {
118-
return;
119-
}
120-
121119
//upgrade the project to engine "V2" if it's not already
122120
if (environment.project.engine === "V1" && body.engine === "V2") {
123121
await this._prisma.project.update({

0 commit comments

Comments
 (0)