Skip to content
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

Not working on serverless edge functions #1623

Closed
MickL opened this issue Feb 10, 2024 · 7 comments
Closed

Not working on serverless edge functions #1623

MickL opened this issue Feb 10, 2024 · 7 comments

Comments

@MickL
Copy link

MickL commented Feb 10, 2024

Seems like nodemailer is not working on edge functions like Cloudflare Workers, Vercel Edge Functions or Deno Deploy.

On Vercel I dont see a very detailed error:

TypeError: Class extends value #<Object> is not a constructor or null
    at (index.mjs:1:370367)
    at (__nitro:middleware.js:1:17)

Probably this is due to Node api being used like 'fs' that does not exist within edge worker functions.

As a workaround instead of nodemailer an external service like resend.com could be used: https://github.com/resend/resend-cloudflare-workers-example/blob/main/worker.js

Related: #1621 #1563

@naeem-qv
Copy link

Seems like nodemailer is not working on edge functions like Cloudflare Workers, Vercel Edge Functions or Deno Deploy.

On Vercel I dont see a very detailed error:

TypeError: Class extends value #<Object> is not a constructor or null
    at (index.mjs:1:370367)
    at (__nitro:middleware.js:1:17)

Probably this is due to Node api being used like 'fs' that does not exist within edge worker functions.

As a workaround instead of nodemailer an external service like resend.com could be used: https://github.com/resend/resend-cloudflare-workers-example/blob/main/worker.js

Related: #1621 #1563

So we can't use nodemailer with nextjs?

@MickL
Copy link
Author

MickL commented Feb 21, 2024

Sure you can use it as long as you dont deploy on Edge Workers

@andris9
Copy link
Member

andris9 commented Feb 27, 2024

Nodemailer does not work in any kind of Workers, only in "real" node.js.

@andris9 andris9 closed this as completed Feb 27, 2024
@MickL
Copy link
Author

MickL commented Mar 3, 2024

This is exactly the point of this issue

@andris9
Copy link
Member

andris9 commented Mar 4, 2024

The runtime for workers is not Node.js, it is more similar to a front-end runtime. That runtime lacks support for raw TCP and TLS APIs required by Nodemailer and as such Nodemailer will never work on it.

@tcurdt
Copy link

tcurdt commented Mar 4, 2024

For example the Cloudflare runtime certainly has limitations.

What works is using the APIs (SES, SendGrid, Mailchannels) directly.
I also looked for some abstraction for these APIs. But nodemailer just ain't that.

@sheecegardezi
Copy link

The runtime for workers is not Node.js, it is more similar to a front-end runtime. That runtime lacks support for raw TCP and TLS APIs required by Nodemailer and as such Nodemailer will never work on it.

@andris9 net is supported now using the flag:

node_compat = true

in wrangler.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants