[PR #5086] [MERGED] fix(telemetry): avoid async import if telemetry disabled, fix for esbuild #31365

Closed
opened 2026-04-17 22:14:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5086
Author: @erquhart
Created: 10/4/2025
Status: Merged
Merged: 10/4/2025
Merged by: @Bekacru

Base: canaryHead: fix/avoid-telemetry-import-when-disabled


📝 Commits (1)

  • 6daf37b fix(telemetry): avoid async import if telemetry disabled, fix for esbuild

📊 Changes

2 files changed (+14 additions, -8 deletions)

View changed files

📝 packages/better-auth/src/init.ts (+11 -7)
📝 packages/better-auth/src/telemetry/index.ts (+3 -1)

📄 Description

These fixes aim to make the latest version of Better Auth compatible with Convex.

Convex's esbuild bundling follows static paths in async imports during bundling, causing telemetry related node dependencies to be bundled for the Convex runtime (which errors during build). This PR uses a variable for the telemetry import path to ensure esbuild doesn't attempt to bundle it.

At runtime, async imports will fail in the Convex runtime specifically. This PR replaces the createTelemetry publish method with a no-op function if telemetry is disabled in options.


Summary by cubic

Prevents telemetry code from being imported when telemetry is disabled, fixing esbuild bundling in Convex and avoiding runtime errors.

  • Bug Fixes
    • Use a variable import path for createTelemetry to stop esbuild from following the dynamic import and bundling node-only telemetry deps.
    • When telemetry is disabled, return a no-op publish function and skip the async import to prevent Convex runtime failures.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5086 **Author:** [@erquhart](https://github.com/erquhart) **Created:** 10/4/2025 **Status:** ✅ Merged **Merged:** 10/4/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/avoid-telemetry-import-when-disabled` --- ### 📝 Commits (1) - [`6daf37b`](https://github.com/better-auth/better-auth/commit/6daf37baf05ab9c44d8fba9d247718bb399ea81f) fix(telemetry): avoid async import if telemetry disabled, fix for esbuild ### 📊 Changes **2 files changed** (+14 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/init.ts` (+11 -7) 📝 `packages/better-auth/src/telemetry/index.ts` (+3 -1) </details> ### 📄 Description These fixes aim to make the latest version of Better Auth compatible with Convex. Convex's esbuild bundling follows static paths in async imports during bundling, causing telemetry related node dependencies to be bundled for the Convex runtime (which errors during build). This PR uses a variable for the telemetry import path to ensure esbuild doesn't attempt to bundle it. At runtime, async imports will fail in the Convex runtime specifically. This PR replaces the createTelemetry `publish` method with a no-op function if telemetry is disabled in options. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Prevents telemetry code from being imported when telemetry is disabled, fixing esbuild bundling in Convex and avoiding runtime errors. - **Bug Fixes** - Use a variable import path for createTelemetry to stop esbuild from following the dynamic import and bundling node-only telemetry deps. - When telemetry is disabled, return a no-op publish function and skip the async import to prevent Convex runtime failures. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 22:14:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#31365