novu icon indicating copy to clipboard operation
novu copied to clipboard

🐛 Bug Report: Delayed digested flow digests but sends notification multiple times

Open sebastiaanviaene opened this issue 2 years ago • 8 comments

📜 Description

My workflow as follows:

  • I delay the messages with a scheduledAt parameter to wait until a certain time (tomorrow 8AM for example)
  • I then put a digest block to combine those delayed messages into a "Daily update mail" for 10 seconds (assuming the workflow won't take much time to send them to the next block)

It seems if I am sending 2 messages like this, it sends me 2 digested notifications (with the same content) instead of 1

👟 Reproduction steps

Make workflow like this:

image image image

With this content in the in-app notification:

Total events in digest: {{step.total_count}}
{{#if step.digest}}
{{#each step.events}}
    {{test}}
 {{/each}}
 {{else}}
 Not a digested template
 {{/if}}

Send 2 events like this:

{
	"name": "test-digest-delay",
    "to": {
        "subscriberId": "3",
        "email": "[email protected]"
    },
    "payload": {
    	"scheduledAt": "2022-10-11T13:42:00.992Z",
    	"test": "1"
    }
}

👍 Expected behavior

It should digest and send me one notification

👎 Actual Behavior with Screenshots

it sends 2 digested notifications

image

💻 Operating system

MacOS

🤖 Node Version

Stable (16.x)

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

sebastiaanviaene avatar Oct 11 '22 13:10 sebastiaanviaene

@ainouzgali could you please take a look at this one? I don't see a reason of why it might not work.

scopsy avatar Oct 11 '22 14:10 scopsy

Yes, I will look into it.

ainouzgali avatar Oct 11 '22 14:10 ainouzgali

@ainouzgali any luck?

sebastiaanviaene avatar Oct 12 '22 07:10 sebastiaanviaene

Unfortunately, no luck yet @sebastiaanviaene . But I'm on it, will keep you updated

ainouzgali avatar Oct 12 '22 08:10 ainouzgali

Were you able to reproduce it?

sebastiaanviaene avatar Oct 12 '22 22:10 sebastiaanviaene

Yes, I've been working on it @sebastiaanviaene. But it's a bit tricky because of the way our queue works.
It's a very specific bug of Digest coming after a Scheduled Delay that has been triggered more than once for the exact same scheduled date. If you need a workaround just for now, you could try scheduling the sendAt parameter for 1 or 2 seconds more than the sendAt of your first trigger.
For example - if your first trigger has "sendAt": "2022-10-12T17:52:15.694Z" then for the next triggers try using "sendAt": "2022-10-12T17:52:17.694Z"

But I am working on a fix - I will keep you updated :)

ainouzgali avatar Oct 13 '22 07:10 ainouzgali

@ainouzgali Thank you for the workaround and looking into it! I see its already fixed 😄

sebastiaanviaene avatar Oct 13 '22 09:10 sebastiaanviaene

Hi @sebastiaanviaene, the fix was merged to main branch. This will be included in the closest release (v0.9.0).

ainouzgali avatar Oct 18 '22 06:10 ainouzgali

Hi, I'm Jarvis 🤖

I'm a bot built to help you with your contribution to Novu. I will add instructions and guides on how to run the subset of the Novu platform associated to this issue and make your first contribution.

This issue was tagged as related to @novu/api and the related code is located at the apps/api folder, here is how I can help you:

First time contributing to Novu?

If that's the first time you want to contribute to Novu here are a few simple steps to get you started:

  1. Fork the repository and clone your fork to your local machine.
  2. Install the dependencies using npm run setup:project.
  3. Create a new branch with the number of the issue, for example: 1454-fix-something-cool and start contributing based on the Contributing Guide or the short guide in the section below.
  4. Create a Pull request and follow the template of creation
Run and test `@novu/api` locally

Run API in watch mode

The easiest way to start the API is to run npm run start:api from the root of the repository

Run API integration tests

To validate your changes or simply to run the e2e tests run npm run start:e2e:api. All the e2e tests have the .e2e.ts suffix and usually are located near the controller files of each module.

github-actions[bot] avatar Oct 28 '22 15:10 github-actions[bot]