SendGrid Contact List Sync Crashing NodeBB
-
@baris Well it's not longer crashing, but I'm just getting:
2023-07-17T00:54:27.021Z [4568/3628540] - info: [plugins/emailer-sendgrid] Synchronizing... 2023-07-17T00:54:27.695Z [4568/3628540] - warn: [plugins/emailer-sendgrid] Unable to synchronize
I've triple checked that the SendGrid API key has access to both the Mail API and Marketing API so that's not causing the issue. Unfortunately that's all the information it's currently giving me.
-
Crashing again:
2023-07-17T01:53:21.480Z [4568/3629500] - info: [plugins/emailer-sendgrid] Synchronizing... 2023-07-17T01:53:22.284Z [4568/3629500] - error: uncaughtException: err is not defined ReferenceError: err is not defined at Emailer.marketing.synchronize (/root/sysadminszone/nodebb/node_modules/nodebb-plugin-emailer-sendgrid/index.js:424:70) at runMicrotasks (<anonymous>) at processTicksAndRejections (node:internal/process/task_queues:96:5) {"date":"Mon Jul 17 2023 01:53:22 GMT+0000 (Coordinated Universal Time)","error":{},"exception":true,"os":{"loadavg":[1.61,0.56,0.25],"uptime":3927883.26},"process":{"argv":["/usr/bin/node","/root/sysadminszone/nodebb/app.js"],"cwd":"/root/sysadminszone/nodebb","execPath":"/usr/bin/node","gid":0,"memoryUsage":{"arrayBuffers":19707881,"external":27309238,"heapTotal":101437440,"heapUsed":97141448,"rss":171921408},"pid":3629500,"uid":0,"version":"v16.20.1"},"stack":"ReferenceError: err is not defined\n at Emailer.marketing.synchronize (/root/sysadminszone/nodebb/node_modules/nodebb-plugin-emailer-sendgrid/index.js:424:70)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)","trace":[{"column":70,"file":"/root/sysadminszone/nodebb/node_modules/nodebb-plugin-emailer-sendgrid/index.js","function":"Emailer.marketing.synchronize","line":424,"method":"synchronize","native":false},{"column":null,"file":null,"function":"runMicrotasks","line":null,"method":null,"native":false},{"column":5,"file":"node:internal/process/task_queues","function":"processTicksAndRejections","line":96,"method":null,"native":false}]} 2023-07-17T01:53:22.285Z [4568/3629500] - error: ReferenceError: err is not defined at Emailer.marketing.synchronize (/root/sysadminszone/nodebb/node_modules/nodebb-plugin-emailer-sendgrid/index.js:424:70) at runMicrotasks (<anonymous>) at processTicksAndRejections (node:internal/process/task_queues:96:5) 2023-07-17T01:53:22.286Z [4568/3629500] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised. 2023-07-17T01:53:22.291Z [4568/3629500] - info: [app] Web server closed to connections. 2023-07-17T01:53:22.307Z [4568/3629500] - info: [app] Live analytics saved.
-
@baris Not much extra information I'm afraid:
2023-07-17T02:14:53.808Z [4568/3630129] - warn: [plugins/emailer-sendgrid] Unable to synchronize. Error: Bad Request at node_modules/@sendgrid/client/src/classes/client.js:146:29 at processTicksAndRejections (node:internal/process/task_queues:96:5)
I wonder if maybe SendGrid changed something in their API that's breaking things?
-
Maybe, this is the request the plugin is making.
await Client.request({ method: 'PUT', url: `/v3/marketing/contacts`, body: { list_ids: [Emailer._settings['marketing.id']], contacts: data.map((entry) => { const fields = ['username', 'fullname'].reduce((memo, prop) => { memo[Emailer._settings[`marketing.fields.${prop}`]] = entry[prop] || ''; return memo; }, {}); return { email: entry.email, custom_fields: fields, }; }), }, });
Do you have marketting.id set in plugin settings? Maybe add some console.logs in the plugin to verify if all the data is passed in.
-
@baris Where would I set that? I don't see any options for it in the emailer plugin settings in ACP nor in the Email settings.
I will note though that when I click on "View list in SendGrid" it does take me to the correct list.
-
@baris I think I may have found the issue, I ended up console logging the
data.map
function toconsole.log({email: entry.email, custom_fields: fields})
and what I discovered is that somehow, some way, a couple of users exist that have zero email associated with them. Which would in fact cause the 400 error I'm experiencing.Deleting those user accounts (no content or posts) resolved the issue.
-
-