nest-modules / mailer

📨 A mailer module for Nest framework (node.js)
https://nest-modules.github.io/mailer/
MIT License
837 stars 176 forks source link

1.11 breaks backward compatibility #1127

Open JonnyBGod opened 6 months ago

JonnyBGod commented 6 months ago

Describe the bug After upgrading to 1.11 or later it faills compilation while using either 'nodemailer-mandrill-transport' or 'nodemailer-mailgun-transport'.

To Reproduce

import mandrillTransport from 'nodemailer-mandrill-transport'

const transport = mandrillTransport({
  auth: {
    apiKey: 'MANDRILL_KEY',
  },
})

Expected behavior It should not break compatibility with older transports that use callbacks intead of promises

Additional context

[ExceptionHandler] transporter.verify(...).then is not a function TypeError: transporter.verify(...).then is not a function
    at MailerService.verifyTransporter (/node_modules/@nestjs-modules/mailer/dist/mailer.service.js:67:14)
    at new MailerService (/node_modules/@nestjs-modules/mailer/dist/mailer.service.js:60:18)
    at Injector.instantiateClass (/node_modules/@nestjs/core/injector/injector.js:365:19)
    at callback (/node_modules/@nestjs/core/injector/injector.js:65:45)
    at Injector.resolveConstructorParams (/node_modules/@nestjs/core/injector/injector.js:144:24)
    at Injector.loadInstance (/node_modules/@nestjs/core/injector/injector.js:70:13)
    at Injector.loadProvider (/node_modules/@nestjs/core/injector/injector.js:97:9)
    at /node_modules/@nestjs/core/injector/instance-loader.js:56:13
    at async Promise.all (index 4)
    at InstanceLoader.createInstancesOfProviders (/node_modules/@nestjs/core/injector/instance-loader.js:55:9)
    at /node_modules/@nestjs/core/injector/instance-loader.js:40:13
    at async Promise.all (index 43)
    at InstanceLoader.createInstances (/node_modules/@nestjs/core/injector/instance-loader.js:39:9)
    at InstanceLoader.createInstancesOfDependencies (/node_modules/@nestjs/core/injector/instance-loader.js:22:13)
    at /node_modules/@nestjs/core/nest-factory.js:108:17
    at Function.asyncRun (/node_modules/@nestjs/core/errors/exceptions-zone.js:22:13) 
domme1908 commented 6 months ago

Yea I can confirm this. Upon updating 1.11.2 i get the following error upon startup: [Nest] 44016 - 29.02.2024, 21:34:11 ERROR [MailerService] Transporter is ready I am not using any custom transport though.

DocAmaroo commented 6 months ago

I can confirm too, my application used SendMailTransport and I received the same errors.

I removed it to use simple object config and I discovered the same error message that @domme1908 referred (see comment above ↑)

randbytes commented 6 months ago

Why I always receiving [MailerService] Transporter is ready ?

Mosheng-Yan commented 6 months ago

Me too, please tell me how to solve it?

gterras commented 6 months ago

About the phantom Transporter is ready this is probably triggered here :

https://github.com/nest-modules/mailer/blob/fce969570ca7fce27340b1f9ebf5cc4dc1546fa9/lib/mailer.service.ts#L113-L114

Since this.transporter is added unconditionally.

aecuto commented 6 months ago

@GFoniX bug!!! verify from https://github.com/nest-modules/mailer/pull/1118

GFoniX commented 6 months ago

Fixed in this PR https://github.com/nest-modules/mailer/pull/1133. Sorry for this inconvenience, I had indeed run npm run test but not with SendGrid. Now, the test has become "optional," and I have added an additional check just in case.