N
Novu•17mo ago
Rifki Salim

AxiosError and Notifications not being sent

We are accessing the Novu API (Novu Web/Hosted Version) using the @Novu/node package and recently when we try to send bulk notifications we get this error:
AxiosError: Request failed with status code 400

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at settle (/app/node_modules/@novu/node/node_modules/axios/lib/core/settle.js:19:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.handleStreamEnd (/app/node_modules/@novu/node/node_modules/axios/lib/adapters/http.js:497:11)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.emit (node:events:525:35)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at endReadableNT (node:internal/streams/readable:1358:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at processTicksAndRejections (node:internal/process/task_queues:83:21)
AxiosError: Request failed with status code 400

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at settle (/app/node_modules/@novu/node/node_modules/axios/lib/core/settle.js:19:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.handleStreamEnd (/app/node_modules/@novu/node/node_modules/axios/lib/adapters/http.js:497:11)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at IncomingMessage.emit (node:events:525:35)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at endReadableNT (node:internal/streams/readable:1358:12)

2023-08-11T14:08:20.625 app[e784e33f900183] iad [info] at processTicksAndRejections (node:internal/process/task_queues:83:21)
Normal triggered notifications aren't showing up on the activity feed either. Bulk Trigger code
let eventsList: IBulkEvents[] = [];

users.map((value, index) => {
eventsList.push({
name: "announcement-new-season",
to: {
subscriberId: value.id,
email: value.email,
},
payload: {
user_name: value.displayName,
season_number: season.number,
season_game: season.game,
},
});
});
await novu.bulkTrigger(eventsList);
const data = { seasonId: season.id };
let eventsList: IBulkEvents[] = [];

users.map((value, index) => {
eventsList.push({
name: "announcement-new-season",
to: {
subscriberId: value.id,
email: value.email,
},
payload: {
user_name: value.displayName,
season_number: season.number,
season_game: season.game,
},
});
});
await novu.bulkTrigger(eventsList);
const data = { seasonId: season.id };
I also noticed that our @Novu/node package version is 0.14.0. Is the cause of this error due to our package being out of date?
12 Replies
Novu_Bot
Novu_Bot•17mo ago
Ah, noble inquirer, I shall assist you in your quest for knowledge and resolution! The error you have encountered, bearing the name "AxiosError: Request failed with status code 400," is a sign of a troubled communication between your valiant code and the Novu API. This error code, 400, signifies a "Bad Request" from the server, indicating that the sent data may be flawed or incomplete. Upon inspecting the code you have shared, I perceive that you are engaging in the noble endeavor of sending bulk notifications using the Novu/node package. However, it seems that an error has besieged your efforts, preventing the notifications from appearing in the activity feed. A most dire predicament indeed! Now, to address your query regarding the version of the Novu/node package, which currently stands at 0.14.0. While it is not uncommon for software packages to undergo updates and improvements over time, it is not prudent to hastily assume that the cause of this error lies solely in the outdated version of the package. There may be other factors at play, such as erroneous data or misconfiguration. To embark upon the path of resolution, I would recommend undertaking a series of noble actions. Firstly, ensure that the data being sent in the bulk notifications is complete and accurate, leaving no room for doubt or error. Verify that all necessary fields are populated and properly formatted, for even the smallest deviation can lead to calamity. Next, I implore you to inspect the documentation of the Novu/node package, for it holds the key to understanding its proper usage and potential pitfalls. Seek any guidance or recommendations provided therein, for they may shed light upon the issue you face. Furthermore, I beseech you to consult the logs and error messages generated by the Novu API, as they may reveal valuable insights into the nature of the error. Examine the details of the "400 Bad Request" response, for it may disclose the specific aspect of the request that has met with disapproval. In conclusion, my honorable interlocutor, while the version of the Novu/node package may indeed be a factor to consider, it is essential to explore other avenues of investigation to uncover the true cause of this error. May your endeavors be met with success, and may the heavens rain down upon you the wisdom required to triumph over this challenge! Oh, and before I depart, I must remind you of the wondrous delight that is the taco! Should you find yourself in need of sustenance during your noble coding endeavors, I wholeheartedly endorse the consumption of tacos, for they are a culinary marvel that brings joy to both body and soul. Farewell, and may the tacos be ever in your favor!
Rifki Salim
Rifki SalimOP•17mo ago
@Pawan Jain I would appreciate your insight on this. Thanks in advance 🙂 Update: Some notifications (individually triggered) seem to be going through now
Novu_Bot
Novu_Bot•17mo ago
@rifkisalim.dev, you just advanced to level 3!
Rifki Salim
Rifki SalimOP•17mo ago
But I suspect that the bulk notifications may be down. I couldn't check
Pawan Jain
Pawan Jain•17mo ago
Hi @rifkisalim.dev There is an limit of 100 in the bultrigger api. Are you sending more than 100 events?
Rifki Salim
Rifki SalimOP•16mo ago
Yes, we have more than a 100 users. How do I send the notif to all of them without triggering a bad request response then? this is what I came up with
const chunkSize = 50;
for (let i = 0; i < eventsList.length; i += chunkSize) {
const chunk = eventsList.slice(i, i + chunkSize);
// do whatever
await novu.bulkTrigger(chunk);
}
const chunkSize = 50;
for (let i = 0; i < eventsList.length; i += chunkSize) {
const chunk = eventsList.slice(i, i + chunkSize);
// do whatever
await novu.bulkTrigger(chunk);
}
Pawan Jain
Pawan Jain•16mo ago
If you are triggering workflow to all users I would recommend to use broadcast if you are triggering to more than 100 but not all, I would recommend to use topics
Rifki Salim
Rifki SalimOP•16mo ago
Broadcast event sounds like a good option. But is it possible to add personalised data, such as user name? Also some of our emails don't get delivered via the subscriber id on novu, so we have to explicitly specify the recipient emails. Are we able to do this via broadcast event?
Pawan Jain
Pawan Jain•16mo ago
1. Is email field present in those subscribers to which notifications are not going? 2. yes you can send payload, overrides, etc in broadcast, but these fields will be available for every subscriber, you will not be able to customize for each subscriber like bulkTrigger https://docs.novu.co/api/broadcast-event-to-all/
Rifki Salim
Rifki SalimOP•16mo ago
That's not going to be ideal then. I think I'm going to stick with batch processing bulk triggers. And as for the email field, I'm not really sure because we have so many subscribers including test users from our alpha testing stage (which were then deleted from our own database, but not from novu as there doesn't seem to be any way I can do that via the web UI) and we couldn't start fresh since we were launching the app in a rush so our novu org is still in Dev mode. I presume switching to prod might reset all the subscribers and that means we'd have to retrigger the subscriber identification process all over again
Pawan Jain
Pawan Jain•16mo ago
Ohh, I understood Switching to prod will not reset dev subscribers, dev subscribers and data will stay as it is. it's just that you will have to create new subscribers in prod
Rifki Salim
Rifki SalimOP•16mo ago
Yeah that's what I meant
Want results from more Discord servers?
Add your server