Open NicolasGorga opened 1 month ago
What is your Redis configuration?
AFAIK a full Redis setup is required for SendGrid to function and I can see the "A fake Redis instance will be used" message being logged.
Hey @irab yeah I was trying to use it with the local-event-bus, since nowhere in the docs I found a statement mentioning it only works with Redis configured.
After setting up a Redis instance it is working with medusa-plugin-sendgrid-typescript, haven't tried with this one since it discouraged me the notion i got that it is not being actively maintained.
I guess the issue should remain Open until they make a correction to the docs, it will hopefully save someone else time, I spent a few days banging my head with something that "should" work by following the docs instructions
@NicolasGorga, the logs you see about the subscribers missing a config are misleading. The subscribers are in fact getting registered, but because they use the old subscriber syntax, our loader will complain.
I just ran through all of the outlined steps and was unfortunately unable to reproduce your issue. What logs are you seeing when the order is placed?
Same here. Currently not working.
Logs when order is placed: image
Hi @NicolasGorga, Thank you a lot! after I had Redis configured it worked fine
Bug report
Describe the bug
When installing the medusa-plugin-sendgrid plugin, configuring a verified single sender in Sendgrid as per Sender Verification, creating en email template and setting the environment variables needed for configuring the plugin to send emails on order_placed events, no emails are sent after generating an order.
Running 'yarn dev' shows warning after initializing plugins:
warn: The subscriber in E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\subscribers\order.js is missing a config. warn: The subscriber in E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\subscribers\restock.js is missing a config. warn: The subscriber in E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\subscribers\user.js is missing a config.
Tried calling endpoint 'sendgrid/send' fro further debugging and got the following error stack, which seems as if the body of the post request is resolved to undefined, which is what gets passed to the sendEmail function in send-email.js:
TypeError: Cannot read properties of undefined (reading 'isMultiple') at MailService.send (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\@sendgrid\mail\src\classes\mail-service.js:184:23) at _callee5$ (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:384:39) at tryCatch (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:17:1360) at Generator. (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:17:4177)
at Generator.next (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:17:2211)
at asyncGeneratorStep (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:18:103)
at _next (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:19:194)
at E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:19:364
at new Promise ()
at SendGridService. (E:\proyectos personales\centr0\temp\sendgrid_test\sendgrid_test\node_modules\medusa-plugin-sendgrid\services\sendgrid.js:19:97)
To discard it being a configuration problem, i created a simple GET custom api route, like this:
`import { MedusaRequest, MedusaResponse } from "@medusajs/medusa";
export const GET = async (req: MedusaRequest, res: MedusaResponse) => { const sendgridService = req.scope.resolve('sendgridService'); const data = await sendgridService.sendNotification('order.placed', {id: 'order_01J4T36SJQ60FH3NT9ATC12S8G'}); res.status(200).send(data); }`
And confirmed the email is sent correctly, so it appears to be a problem with the emission / subscription to the event.
System information
Medusa version (including plugins): Medusa: 1.20.9 and medusa-plugin-sendgrid: 1.3.13 Node.js version: 20 Database: postgres Operating system: Windows Browser (if relevant):
Steps to reproduce the behavior
Expected behavior
After linking an event to a Sendgrid template in plugin options, when event is emitted, the email to be sent
When making a POST request to 'sendgrid/send' api route, with required body properties, for the email to be sent
Screenshots