Skip to content

SendGrid setApiKey() fails in Server Actions with Turbopack #80636

@kyeb

Description

@kyeb

Bug Report

Description: @sendgrid/mail.setApiKey() throws TypeError: Cannot read properties of undefined (reading 'client') when called from Server Actions with Turbopack enabled.

Error:
TypeError: Cannot read properties of undefined (reading 'client')

Reproduction: https://github.com/kyeb/sendgrid-turbopack-repro

Minimal requirements to reproduce:

  • Next.js 15.4.0-canary
  • Turbopack enabled (--turbo)
  • Server Actions ('use server')
  • SendGrid's setApiKey() call

Working configurations:

  • Regular API routes (even with Turbopack)
  • Server Actions with webpack bundler

Failing configuration:

  • Server Actions + Turbopack

Environment:

  • Next.js: 15.4.0-canary.84
  • @sendgrid/mail: ^8.1.5
  • Node.js: v22.14.0

The issue appears to be specific to how Turbopack handles the SendGrid module's internal state in Server Actions context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalid linkThe issue was auto-closed due to a missing/invalid reproduction link. A new issue should be opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions