stack icon indicating copy to clipboard operation
stack copied to clipboard

Bug: Maximum call stack size exceeded when sending email verification code

Open wail-asad opened this issue 3 months ago • 0 comments

Description:

Bug Report: Email Verification Failure with Custom SMTP Server

When attempting to send an email verification code through the Stack Auth dashboard, the request fails with a 500 error and "Maximum call stack size exceeded" error.


Environment

  • Stack Auth Version: Latest (Docker deployment)
  • Deployment: Docker Compose with custom domain
  • Email Server: Mailu (self-hosted SMTP)
  • Node Version: v22.9.0
  • Domain: Custom domain with HTTPS

Steps to Reproduce

  1. Set up Stack Auth with custom SMTP configuration (see configuration below)
  2. Navigate to Stack Auth dashboard → Account Settings
  3. Click "Send Verification Email"
  4. Error occurs immediately

Expected Behavior

  • Verification email should be sent successfully
  • User should receive verification code at their email address

Actual Behavior

Frontend Error:

StackAssertionError: Failed to send request to https://authapi.example.com/api/v1/contact-channels/me/e606efe2-f80c-420e-bf70-0553da2d0dbd/send-verification-code: 500

Something went wrong. Please make sure the data you entered is correct.

Backend Error:

Captured error in route-handler: RangeError: Maximum call stack size exceeded

Email Configuration

Docker Environment Variables:

# SMTP Configuration (Mailu server)
STACK_EMAIL_HOST=mail-server
STACK_EMAIL_PORT=465
[email protected]
STACK_EMAIL_PASSWORD=your_password_here
[email protected]

# Stack Auth API
NEXT_PUBLIC_STACK_API_URL=https://authapi.example.com
NEXT_PUBLIC_STACK_PROJECT_ID=412c863e-afb8-41ef-8c78-20414a58f26f

Email Server Details:

  • Server Type: Mailu (self-hosted)
  • Port 465: SSL/TLS (Working - verified independently)
  • Port 587: Not enabled
  • Port 25: Blocked by DMARC policy

Independent Email Test (Successful)

We verified the SMTP server works correctly outside of Stack Auth using the following test:

// test-email.js - Ran inside Stack Auth Docker container
const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
  host: 'mail-server',
  port: 465,
  secure: true,
  auth: {
    user: '[email protected]',
    pass: 'your_password_here'
  },
  tls: {
    rejectUnauthorized: false
  }
});

// Test email send
transporter.sendMail({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Test Email',
  text: 'This is a test email',
  html: '<h1>Test Email</h1><p>Email sent successfully!</p>'
}).then(info => {
  console.log('✅ Email sent successfully!');
  console.log('Message ID:', info.messageId);
  console.log('Response:', info.response);
}).catch(err => {
  console.error('❌ Error:', err.message);
});

Result:

✅ Connection successful!
✅ Email sent successfully!
📧 Message ID: <[email protected]>
📊 Response: 250 2.0.0 Ok: queued as E3D7D200CB5

wail-asad avatar Oct 25 '25 23:10 wail-asad