@@ -45,6 +45,14 @@ export class IndexDeploymentService extends BaseService {
45
45
46
46
// just broadcast for now - there should only ever be one provider connected
47
47
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
+
48
56
const responses = await socketIo . providerNamespace . timeout ( 30_000 ) . emitWithAck ( "INDEX" , {
49
57
version : "v1" ,
50
58
shortCode : deployment . shortCode ,
@@ -61,15 +69,7 @@ export class IndexDeploymentService extends BaseService {
61
69
62
70
logger . debug ( "Index ACK received" , { responses } ) ;
63
71
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 ) {
73
73
const indexFailed = new DeploymentIndexFailed ( ) ;
74
74
75
75
for ( const response of responses ) {
@@ -83,12 +83,20 @@ export class IndexDeploymentService extends BaseService {
83
83
84
84
const indexFailed = new DeploymentIndexFailed ( ) ;
85
85
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 ) ;
92
100
}
93
101
}
94
102
0 commit comments