N
Novu12mo ago
Khong

Cancelling Delayed Jobs Edge Case

Hi Novu team! We have this problem where if we make a delayed broadcast to many users, say, an announcement of some upcoming event made by an admin. Let's say as soon as the admin hit the "send" button, they realize immediately that the sent announcement has wrong details. We have implemented a button that when pressed, triggers the cancel triggered event endpoint (https://docs.novu.co/api-reference/events/cancel-triggered-event). While that works most of the time, sometimes it doesn't. We have a lot of users on staging; currently, it takes around 1 minute for all jobs to be chunked and added to the subscriber process queue. If I try cancelling the triggered event within this one minute window, some jobs won't be cancelled because they don't yet exist at the point cancel-triggered-event is called (basically in the middle of this method https://github.com/novuhq/novu/blob/next/packages/application-generic/src/usecases/trigger-broadcast/trigger-broadcast.usecase.ts#L49-L75). Is there a workaround for this or am I missing something? A possible workaround I can think of would be some ways of finding out somehow whether all jobs with a transaction id have been scheduled. We can disable the cancel delayed notification button in the meantime. I could also just assume that the jobs creation will always take 1 - 2 minutes, but that'd be the last resort. Thanks in advance!
2 Replies
Pawan Jain
Pawan Jain12mo ago
Hi @Khong Thanks for sharing the issue in detail here delayed broadcast means that delay step is added in workflow to be triggered
Khong
KhongOP12mo ago
Hi @Pawan Jain ! I understand. The point I was trying to make was that if the cancel event endpoint was called too soon, some delayed jobs won't be cancelled.
Want results from more Discord servers?
Add your server