-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
EmailProvider + nodemailer fails with Vercel Edge Runtime due to Node.js 'stream' dependency #8357
Comments
Tried raising an issue with
nodemailer/nodemailer#1563 (comment) Given this, can |
For now, I can probably use HTTP-based Email Provider to get around the issue |
This is expected. |
The link to the HTTP email provider leads to 404. Are the updated guides on this? |
Why this was closed @balazsorban44 ? Maybe documentation needs to be updated at least ? It's kinda weird when you see nodemailer there with next.js, but when you try it you see the error |
Yes, this should be reopened. Given that in the docs you explicitly support nodemailer. |
Agreed, this should be reopened. Following the official Email Provider docs for Nodemailer and next.js it produces the same error: https://authjs.dev/getting-started/authentication/email Error: The edge runtime does not support Node.js 'stream' module. |
so basically nodemailer cannot be used in any nextjs apps + nextauth? That's kind of weird while by default nextjs uses nodejs runtime. Or am I missing something? |
This seems to be exactly the case of edge-compatibility. In the current state of next-auth-example repository, middleware.ts imports the NextAuth object from auth.ts, but middleware is run in edge environment. Nodemailer is not edge-compatible library, so you have to split up the configuration and use only edge-compatible parts in edge environments (such as middleware). Just follow the example in given link and avoid using Nodemailer provider in edge environments. But I think it is not necessary to reopen this, the email provider documentation doesn't necessarily state that it will work with next-auth-example nor the next-auth-example uses the Nodemailer provider. Additionally, there is an explicit documentation available describing edge compatibility, that covers the problem in this issue. |
1+ same issue i'm facing |
Environment
System:
OS: Linux 5.19 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (4) x64 Intel(R) Core(TM) i7-10600U CPU @ 2.80GHz
Memory: 1.86 GB / 16.00 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
pnpm: 8.6.10 - ~/.local/share/pnpm/pnpm
Browsers:
Chrome: 108.0.5359.124
Reproduction URL
https://github.com/nextauthjs/next-auth-example
Describe the issue
Due to nodemailer's dependency on Node.js 'stream' module, it doesn't work with vercel's edge runtime.
Since
EmailProvider
hasnodemailer
as peer dependency importing it in a route marked as edge runtime throws below error -https://nextjs.org/docs/messages/node-module-in-edge-runtime
How to reproduce
nodemailer
EmailProvider
in a route.ts that's marked as edge runtime usingexport const runtime = 'edge'
pnpm run build
Expected behavior
Decouple EmailProvider and
nodemailer
so it doesn't throw an errorThe text was updated successfully, but these errors were encountered: