Skip to content

Commit 6b2d7f1

Browse files
authored
Merge pull request #30 from code0-tech/feat/#29
Retry connection to aquila on failure
2 parents 66fd9a7 + 03baa83 commit 6b2d7f1

4 files changed

Lines changed: 20 additions & 24 deletions

File tree

actions/gls-action/src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,14 @@ action.on(CodeZeroEvent.error, (error: Error) => {
176176
console.error("Stream error:", error.message);
177177
console.log("Attempting to reconnect in 5s...");
178178
setTimeout(() => {
179-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
180-
console.error("Reconnect failed:", err);
181-
});
179+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
180+
action.emit(CodeZeroEvent.error, err);
181+
})
182182
}, 5000);
183183
});
184184

185-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
186-
console.error("Failed to connect:", err);
187-
process.exit(1);
185+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
186+
action.emit(CodeZeroEvent.error, err);
188187
});
189188

190189
action.on(CodeZeroEvent.moduleUpdated, (message: any) => {

actions/shopify-action/src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,14 @@ action.on(CodeZeroEvent.error, (error: Error) => {
5252
console.error("Stream error:", error.message);
5353
console.log("Attempting to reconnect in 5s...");
5454
setTimeout(() => {
55-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
56-
console.error("Reconnect failed:", err);
57-
});
55+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
56+
action.emit(CodeZeroEvent.error, err);
57+
})
5858
}, 5000);
5959
});
6060

61-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
62-
console.error("Failed to connect:", err);
63-
process.exit(1);
61+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
62+
action.emit(CodeZeroEvent.error, err);
6463
});
6564

6665
action.on(CodeZeroEvent.moduleUpdated, (message: any) => {

actions/shopware-action/src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ action.on(CodeZeroEvent.error, (error: Error) => {
3232
console.error("Stream error:", error.message);
3333
console.log("Attempting to reconnect in 5s...");
3434
setTimeout(() => {
35-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
36-
console.error("Reconnect failed:", err);
37-
});
35+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
36+
action.emit(CodeZeroEvent.error, err);
37+
})
3838
}, 5000);
3939
});
4040

41-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
42-
console.error("Failed to connect:", err);
43-
process.exit(1);
41+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
42+
action.emit(CodeZeroEvent.error, err);
4443
});
4544

4645
action.on(CodeZeroEvent.moduleUpdated, (message: any) => {

actions/woocommerce-action/src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ action.on(CodeZeroEvent.error, (error: Error) => {
2828
console.error("Stream error:", error.message);
2929
console.log("Attempting to reconnect in 5s...");
3030
setTimeout(() => {
31-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
32-
console.error("Reconnect failed:", err);
33-
});
31+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
32+
action.emit(CodeZeroEvent.error, err);
33+
})
3434
}, 5000);
3535
});
3636

37-
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: unknown) => {
38-
console.error("Failed to connect:", err);
39-
process.exit(1);
37+
action.connect(process.env.AUTH_TOKEN ?? "your_auth_token_here").catch((err: Error) => {
38+
action.emit(CodeZeroEvent.error, err);
4039
});
4140

4241
action.on(CodeZeroEvent.moduleUpdated, (message: any) => {

0 commit comments

Comments
 (0)