Skip to content

Commit fa8f211

Browse files
committed
Invalidate event cache on duplicate key error
When a DB duplicate key error indicates the event already exists, clear any cached null result so a subsequent fetch retrieves the newly created document. This change computes the event cache key via getEventCacheKey(projectId, uniqueEventHash) and deletes it (this.cache.del) before retrying handle(task), preventing stale null caches from causing missed event repetitions.
1 parent 360e31a commit fa8f211

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

workers/grouper/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ export default class GrouperWorker extends Worker {
226226
* and we need to process this event as repetition
227227
*/
228228
if (e.code?.toString() === DB_DUPLICATE_KEY_ERROR) {
229+
/**
230+
* Invalidate cached null from getEvent so the retry
231+
* fetches the now-existing document from the database
232+
*/
233+
const eventCacheKey = await this.getEventCacheKey(task.projectId, uniqueEventHash);
234+
235+
this.cache.del(eventCacheKey);
236+
229237
await this.handle(task);
230238

231239
return;

0 commit comments

Comments
 (0)