New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minification is messing up node-fetch's detection of abort signals #153
Comments
Hold it. I just realized I have the wrong package... nodemailer-mailgun-transport uses https://npm.im/mailgun-js and this is https://npm.im/mailgun.js 🤦 Still, the minification and bundling this project is probably not great 😅 |
Scratch that last comment... Sorry, the naming of this stuff is pretty confusing. Perhaps consider updating the repo name to |
Just realized why this was working a few weeks ago and suddenly stopped working. 8 days ago, So yeah, anyway, I'm not sure why nobody else has reported this issue because from what I can tell, this shouldn't work for anyone using |
Just stumbled upon this same issue and I can confirm |
I am having the same issue |
Related #101. The workarounds don't seem to be ideal though... |
Experiencing the same with "vanilla" mailgun.js in a Next.js serverless function. |
Me too. I've switched back to https://github.com/mailgun/mailgun-js-boland until this is resolved. |
Is it faster/better than SMTP? Came here to replace nodemailer SMTP transport with this. |
I've been using it for a while, and, although it's no longer maintained, it's been working fine for sending emails, which is all I've used it for. From the docs:
|
For anyone else who only really needs to send simple emails (like me), here's what I wrote to do that with the API directly: type MailgunMessage = {
to: string
from: string
subject: string
text: string
html: string
}
const auth = `${Buffer.from(`api:${mailgunSendingKey}`).toString('base64')}`
function sendEmail(message: MailgunMessage) {
return fetch(`https://api.mailgun.net/v3/${mailgunDomain}/messages`, {
method: 'post',
body: new URLSearchParams(message),
headers: {
Authorization: `Basic ${auth}`,
},
})
} Docs:
Look mah, no dependencies! |
Hello @kentcdodds |
I'm using
nodemailer-mailgun-transport
. When attempting to calltransporter.sendMail
, I'm getting:The stack trace is kinda useless because it's minified. Also, because mailgun-js bundles all its deps with webpack, it's pretty difficult to find, but I'm pretty sure here's where the mailgun-js code gets involved: https://github.com/mailgun/mailgun-js/blob/28c71ded8b15dfa84d5933c9d458b834aa952d7a/lib/request.ts#L76
After investigating, I realized that node-fetch attempts to validate whether
signal
is anAbortSignal
based on the name of the constructor.In the latest stable version of node-fetch:
https://github.com/node-fetch/node-fetch/blob/v2.6.1/src/request.js#L42
And in the v3 beta it's still based on the name, but is implemented slightly differently:
https://github.com/node-fetch/node-fetch/blob/v3.0.0-beta.9/src/utils/is.js
In any case, the minification of mailgun-js is causing this issue.
Suggested solution
At the very least, don't minify. This would solve the problem. Also, you may have a reason to bundle, but that's pretty unusual so I'm curious why you're doing it. Can you avoid it? In my experience people handle bundling themselves for stuff like this.
The text was updated successfully, but these errors were encountered: