NovuN
Novu2y ago
ninadk

Delete subscriber does not delete their notifications

I am deleting the test subscribers when re-seeding the db with the following code:
export async function deleteSubscriber(subscriberId: string) {
  try {
    return await novu.subscribers.delete(subscriberId);
  } catch (error: unknown) {
    console.error(error);
    return { error: 'Error deleting subscribers.' };
  }
}

  const subscribers = await getAllSubscribers();
  const deletePromises: Promise<unknown>[] = [];

  subscribers.forEach(subscriber => {
    deletePromises.push(deleteSubscriber(subscriber.subscriberId));
  });

  await Promise.all(deletePromises);


The promises all seem to resolve successfully. But when I recreate the subscribers, the ones that take on an ID of a previously existing subscriber have their notifications show up. The docs suggest that deleting a subscriber will cascade on their notifications so I'm not sure what the problem is. Could it have to do with active/pending notifications?

Note that even though the notification shows up and is returned from the get sub notifications API, when I tried to act on it, I got the following 400 error: message: "Message with the id: 660bd381d787d568ef3afe3b was not found for this environment. Make sure to address correct message before trying t…".
Novu
Novu is an open-source notification infrastructure, built for engineering teams to help them build rich product notification experiences.
Was this page helpful?