Skip to content

Commit 824a620

Browse files
committed
Fix deployments stuck in deploying state
1 parent a0984d5 commit 824a620

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ export class IndexDeploymentService extends BaseService {
4545

4646
// just broadcast for now - there should only ever be one provider connected
4747
try {
48+
// timeout the deployment if 180 seconds have passed and the deployment is still not indexed
49+
await TimeoutDeploymentService.enqueue(
50+
deployment.id,
51+
"DEPLOYING",
52+
"Could not index deployment in time",
53+
new Date(Date.now() + 180_000)
54+
);
55+
4856
const responses = await socketIo.providerNamespace.timeout(30_000).emitWithAck("INDEX", {
4957
version: "v1",
5058
shortCode: deployment.shortCode,
@@ -61,15 +69,7 @@ export class IndexDeploymentService extends BaseService {
6169

6270
logger.debug("Index ACK received", { responses });
6371

64-
if (responses.length === 0) {
65-
// timeout the deployment if 180 seconds have passed and the deployment is still not indexed
66-
await TimeoutDeploymentService.enqueue(
67-
deployment.id,
68-
"DEPLOYING",
69-
"Could not index deployment in time",
70-
new Date(Date.now() + 180_000)
71-
);
72-
} else {
72+
if (responses.length > 0) {
7373
const indexFailed = new DeploymentIndexFailed();
7474

7575
for (const response of responses) {
@@ -83,12 +83,20 @@ export class IndexDeploymentService extends BaseService {
8383

8484
const indexFailed = new DeploymentIndexFailed();
8585

86-
await indexFailed.call(
87-
deployment.friendlyId,
88-
error instanceof Error
89-
? { message: error.message, name: error.name }
90-
: { message: "Could not index deployment in time", name: "TimeoutError" }
91-
);
86+
let indexError = {
87+
message: `Could not index deployment: ${error}`,
88+
name: "IndexError",
89+
};
90+
91+
if (error instanceof Error) {
92+
if (error.message === "operation has timed out") {
93+
indexError = { message: "Provider failed to respond in time", name: "TimeoutError" };
94+
} else {
95+
indexError = { message: error.message, name: error.name };
96+
}
97+
}
98+
99+
await indexFailed.call(deployment.friendlyId, indexError);
92100
}
93101
}
94102

0 commit comments

Comments
 (0)