Skip to content

Commit ed17a62

Browse files
committed
fix: revert .catch() swallowing — let queue failures crash process
1 parent 5ae4caa commit ed17a62

3 files changed

Lines changed: 54 additions & 90 deletions

File tree

src/app.module.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ export class AppModule implements OnApplicationBootstrap {
142142

143143
public async onApplicationBootstrap() {
144144
try {
145-
this.discordBot.setup().catch((error) => {
146-
this.logger.error("Discord bot setup failed", error);
147-
});
145+
void this.discordBot.setup();
148146
await this.typesense.setup();
149147
await this.system.detectFeatures();
150148
} catch (error) {

src/matches/matches.module.ts

Lines changed: 49 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -125,93 +125,67 @@ export class MatchesModule implements NestModule {
125125
return;
126126
}
127127

128-
scheduleMatchQueue
129-
.add(
130-
CheckForScheduledMatches.name,
131-
{},
132-
{
133-
repeat: {
134-
pattern: "* * * * *",
135-
},
128+
void scheduleMatchQueue.add(
129+
CheckForScheduledMatches.name,
130+
{},
131+
{
132+
repeat: {
133+
pattern: "* * * * *",
136134
},
137-
)
138-
.catch((err) => {
139-
this.logger.error("Failed to add CheckForScheduledMatches job", err);
140-
});
135+
},
136+
);
141137

142-
scheduleMatchQueue
143-
.add(
144-
CancelExpiredMatches.name,
145-
{},
146-
{
147-
repeat: {
148-
pattern: "* * * * *",
149-
},
138+
void scheduleMatchQueue.add(
139+
CancelExpiredMatches.name,
140+
{},
141+
{
142+
repeat: {
143+
pattern: "* * * * *",
150144
},
151-
)
152-
.catch((err) => {
153-
this.logger.error("Failed to add CancelExpiredMatches job", err);
154-
});
145+
},
146+
);
155147

156-
scheduleMatchQueue
157-
.add(
158-
RemoveCancelledMatches.name,
159-
{},
160-
{
161-
repeat: {
162-
pattern: "* * * * *",
163-
},
148+
void scheduleMatchQueue.add(
149+
RemoveCancelledMatches.name,
150+
{},
151+
{
152+
repeat: {
153+
pattern: "* * * * *",
164154
},
165-
)
166-
.catch((err) => {
167-
this.logger.error("Failed to add RemoveCancelledMatches job", err);
168-
});
155+
},
156+
);
169157

170-
matchServersQueue
171-
.add(
172-
CheckForTournamentStart.name,
173-
{},
174-
{
175-
repeat: {
176-
pattern: "* * * * *",
177-
},
158+
void matchServersQueue.add(
159+
CheckForTournamentStart.name,
160+
{},
161+
{
162+
repeat: {
163+
pattern: "* * * * *",
178164
},
179-
)
180-
.catch((err) => {
181-
this.logger.error("Failed to add CheckForTournamentStart job", err);
182-
});
165+
},
166+
);
183167

184-
matchServersQueue
185-
.add(
186-
CleanAbandonedMatches.name,
187-
{},
188-
{
189-
repeat: {
190-
pattern: "0 0 * * *",
191-
},
168+
void matchServersQueue.add(
169+
CleanAbandonedMatches.name,
170+
{},
171+
{
172+
repeat: {
173+
pattern: "0 0 * * *",
192174
},
193-
)
194-
.catch((err) => {
195-
this.logger.error("Failed to add CleanAbandonedMatches job", err);
196-
});
175+
},
176+
);
197177

198-
matchServersQueue
199-
.add(
200-
CancelInvalidTournaments.name,
201-
{},
202-
{
203-
repeat: {
204-
pattern: "* * * * *",
205-
},
178+
void matchServersQueue.add(
179+
CancelInvalidTournaments.name,
180+
{},
181+
{
182+
repeat: {
183+
pattern: "* * * * *",
206184
},
207-
)
208-
.catch((err) => {
209-
this.logger.error("Failed to add CancelInvalidTournaments job", err);
210-
});
185+
},
186+
);
211187

212-
this.generatePlayerRatings().catch((err) => {
213-
this.logger.error("Failed to generate player ratings", err);
214-
});
188+
void this.generatePlayerRatings();
215189
}
216190

217191
/**

src/sockets/sockets.service.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ export class SocketsService {
3333

3434
const sub = this.redisManager.getConnection("sub");
3535

36-
sub.subscribe("broadcast-message").catch((err) => {
37-
this.logger.error("Failed to subscribe to broadcast-message", err);
38-
});
39-
sub.subscribe("send-message-to-steam-id").catch((err) => {
40-
this.logger.error("Failed to subscribe to send-message-to-steam-id", err);
41-
});
36+
void sub.subscribe("broadcast-message");
37+
void sub.subscribe("send-message-to-steam-id");
4238
sub.on("message", (channel, message) => {
4339
const { steamId, event, data } = JSON.parse(message) as {
4440
steamId: string;
@@ -48,14 +44,10 @@ export class SocketsService {
4844

4945
switch (channel) {
5046
case "broadcast-message":
51-
this.broadcastMessage(event, data).catch((err) => {
52-
this.logger.error("broadcast-message error", err);
53-
});
47+
void this.broadcastMessage(event, data);
5448
break;
5549
case "send-message-to-steam-id":
56-
this.sendMessageToSteamId(steamId, event, data).catch((err) => {
57-
this.logger.error("send-message-to-steam-id error", err);
58-
});
50+
void this.sendMessageToSteamId(steamId, event, data);
5951
break;
6052
}
6153
});

0 commit comments

Comments
 (0)