Skip to content

Commit a2ba875

Browse files
committed
fix(grouper): get matching pattern fix
1 parent 8e36c73 commit a2ba875

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

workers/grouper/src/index.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,23 @@ export default class GrouperWorker extends Worker {
267267
if (patterns && patterns.length > 0) {
268268
const matchingPattern = await this.findMatchingPattern(patterns, event);
269269

270-
if (matchingPattern !== null) {
271-
const originalEvent = await this.cache.get(`${projectId}:${matchingPattern}:originalEvent`, async () => {
272-
return await this.eventsDb.getConnection()
273-
.collection(`events:${projectId}`)
274-
.findOne(
275-
{ 'payload.title': { $regex: matchingPattern } },
276-
{ sort: { _id: 1 } }
277-
);
278-
});
279-
280-
this.logger.info(`original event for pattern: ${JSON.stringify(originalEvent)}`);
270+
if (matchingPattern !== null && matchingPattern !== undefined) {
271+
try {
272+
const originalEvent = await this.cache.get(`${projectId}:${matchingPattern}:originalEvent`, async () => {
273+
return await this.eventsDb.getConnection()
274+
.collection(`events:${projectId}`)
275+
.findOne(
276+
{ 'payload.title': { $regex: matchingPattern } },
277+
{ sort: { _id: 1 } }
278+
);
279+
});
280+
this.logger.info(`original event for pattern: ${JSON.stringify(originalEvent)}`);
281281

282-
if (originalEvent) {
283-
return originalEvent;
282+
if (originalEvent) {
283+
return originalEvent;
284+
}
285+
} catch (e) {
286+
this.logger.error(`Error while getting original event for pattern ${matchingPattern}`)
284287
}
285288
}
286289
}

0 commit comments

Comments
 (0)