minification is messing up node-fetch's detection of abort signals
See original GitHub issueI’m using nodemailer-mailgun-transport
. When attempting to call transporter.sendMail
, I’m getting:
TypeError: Expected signal to be an instanceof AbortSignal
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 an AbortSignal
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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:12 (1 by maintainers)
Top GitHub Comments
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:
Docs:
Look mah, no dependencies!
Just realized why this was working a few weeks ago and suddenly stopped working. 8 days ago,
nodemailer-mailgun-transport
switched from the oldmailgun-js
to thismailgun.js
: https://github.com/orliesaurus/nodemailer-mailgun-transport/commit/9c6596ac48f3371291a63e2cf700a87ba450067aSo 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
mailgun.js
on the server.