Skip to content

Commit

Permalink
fix: crash in synchronize due to double headers sent
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Jul 16, 2023
1 parent 8b55c8c commit ef7f2fb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,10 @@ Emailer.marketing.getCount = async () => {

Emailer.marketing.synchronize = async (req, res) => {
winston.info('[plugins/emailer-sendgrid] Synchronizing...');
await batch.processSortedSet('users:joindate', async (uids) => {
const data = await user.getUsersFields(uids, ['username', 'email', 'fullname']);
try {
try {
await batch.processSortedSet('users:joindate', async (uids) => {
const data = await user.getUsersFields(uids, ['username', 'email', 'fullname']);

await Client.request({
method: 'PUT',
url: `/v3/marketing/contacts`,
Expand All @@ -418,13 +419,12 @@ Emailer.marketing.synchronize = async (req, res) => {
}),
},
});
} catch (e) {
winston.warn('[plugins/emailer-sendgrid] Unable to synchronize.');
res.sendStatus(500);
// console.log(e.response.body);
}
}, { batch: 500, interval: 100 });

}, { batch: 500, interval: 100 });
} catch (e) {
winston.warn('[plugins/emailer-sendgrid] Unable to synchronize.');
res.sendStatus(500);
return;
}
winston.info('[plugins/emailer-sendgrid] Synchronization complete.');
res.sendStatus(200);
};
Expand Down

0 comments on commit ef7f2fb

Please sign in to comment.