Runtime warning on Cloudflare Edge with v1.3.8 beta #1835

Closed
opened 2026-03-13 09:06:58 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @bytaesu on GitHub (Sep 3, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  • Deploy Better Auth v1.3.7 to Cloudflare Workers → works correctly.

  • Deploy Better Auth v1.3.8 beta to Cloudflare Workers → runtime warnings appear.

Current vs. Expected behavior

  • Current behavior: Runtime warnings appear on Cloudflare Edge due to some runtime dependencies included in the package.

  • Expected behavior: Since Better Auth is a TypeScript library, the package should not include runtime-only dependencies that break in Edge environments.

What version of Better Auth are you using?

1.3.8-beta.11

System info

System:
    OS: macOS 15.6.1
    CPU: (12) arm64 Apple M4 Pro
  Browsers:
    Chrome: 139.0.7258.155
    Safari: 18.6

Which area(s) are affected? (Select all that apply)

Backend

Additional context

Image

The build error points to this file kysely-adapter/dialect.ts

Recently I submitted a PR to fix a Next.js build error in the beta version #4360, but I don’t think this is just a build error issue. I hope that Better Auth can be used in TypeScript without runtime issues in any environment.

If there are any challenges in resolving this issue, please let me know and I’m happy to help

Originally created by @bytaesu on GitHub (Sep 3, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce - Deploy Better Auth v1.3.7 to Cloudflare Workers → works correctly. - Deploy Better Auth v1.3.8 beta to Cloudflare Workers → runtime warnings appear. ### Current vs. Expected behavior - Current behavior: Runtime warnings appear on Cloudflare Edge due to some runtime dependencies included in the package. - Expected behavior: Since Better Auth is a TypeScript library, the package should not include runtime-only dependencies that break in Edge environments. ### What version of Better Auth are you using? 1.3.8-beta.11 ### System info ```bash System: OS: macOS 15.6.1 CPU: (12) arm64 Apple M4 Pro Browsers: Chrome: 139.0.7258.155 Safari: 18.6 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Additional context <img width="1052" height="460" alt="Image" src="https://github.com/user-attachments/assets/e35a46be-8ba8-4040-aa9d-b0e056438cb9" /> The build error points to this file [kysely-adapter/dialect.ts](https://github.com/better-auth/better-auth/blob/canary/packages/better-auth/src/adapters/kysely-adapter/dialect.ts) Recently I submitted a PR to fix a Next.js build error in the beta version [#4360](https://github.com/better-auth/better-auth/pull/4360), but I don’t think this is just a build error issue. I hope that Better Auth can be used in TypeScript without runtime issues in any environment. If there are any challenges in resolving this issue, please let me know and I’m happy to help
GiteaMirror added the adapter label 2026-03-13 09:06:58 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 3, 2025):

Hi @bytaesu! I'm Dosu and I’m helping the better-auth team.

The runtime warnings on Cloudflare Edge with Better Auth v1.3.8-beta.11 are caused by two main factors: (1) the inclusion of Node.js-specific modules like os, path, and node:sqlite in the package, and (2) the way these dependencies are imported—even with dynamic imports and try-catch, bundlers for Edge environments may still include or process these modules, leading to warnings or errors even if you don't use SQLite or telemetry features. This issue was introduced by recent changes to the kysely-adapter and telemetry features in the 1.3.8 beta series [1] [2].

Disabling telemetry in your config does not prevent these runtime errors, because the imports are still present and processed by the bundler [3]. Using a pre-telemetry version (≤1.3.4) or a version after PR #3947 (once released) with proper runtime checks and lazy imports can help. Alternatively, you can patch your build to wrap Node.js imports in try-catch blocks, but this may not fully resolve bundler warnings if the modules are still statically referenced.

If you need to use Better Auth on Cloudflare Workers or other Edge runtimes, the safest current workaround is to use v1.3.7 or earlier, or to patch out the problematic imports until a version with improved runtime guards is released. If you want to help, testing future betas or contributing a patch that further isolates Node.js-only code from the main bundle would be valuable.

References:

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 3, 2025): <!-- Greeting --> Hi @bytaesu! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The runtime warnings on Cloudflare Edge with Better Auth v1.3.8-beta.11 are caused by two main factors: (1) the inclusion of Node.js-specific modules like `os`, `path`, and `node:sqlite` in the package, and (2) the way these dependencies are imported—even with dynamic imports and try-catch, bundlers for Edge environments may still include or process these modules, leading to warnings or errors even if you don't use SQLite or telemetry features. This issue was introduced by recent changes to the kysely-adapter and telemetry features in the 1.3.8 beta series [[1](https://github.com/better-auth/better-auth/pull/3869)] [[2](https://github.com/better-auth/better-auth/pull/3822)]. Disabling telemetry in your config does not prevent these runtime errors, because the imports are still present and processed by the bundler [[3](https://github.com/better-auth/better-auth/issues/3973)]. Using a pre-telemetry version (≤1.3.4) or a version after PR #3947 (once released) with proper runtime checks and lazy imports can help. Alternatively, you can patch your build to wrap Node.js imports in try-catch blocks, but this may not fully resolve bundler warnings if the modules are still statically referenced. If you need to use Better Auth on Cloudflare Workers or other Edge runtimes, the safest current workaround is to use v1.3.7 or earlier, or to patch out the problematic imports until a version with improved runtime guards is released. If you want to help, testing future betas or contributing a patch that further isolates Node.js-only code from the main bundle would be valuable. References: - [Telemetry and Node.js import issue](https://github.com/better-auth/better-auth/issues/3973) - [Kysely adapter/node:sqlite PR](https://github.com/better-auth/better-auth/pull/3869) - [Telemetry feature PR](https://github.com/better-auth/better-auth/pull/3822) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/7f0375f9-7278-4427-a151-70ec39d85ba1?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/7f0375f9-7278-4427-a151-70ec39d85ba1?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/7f0375f9-7278-4427-a151-70ec39d85ba1?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/7f0375f9-7278-4427-a151-70ec39d85ba1?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/7f0375f9-7278-4427-a151-70ec39d85ba1?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/7f0375f9-7278-4427-a151-70ec39d85ba1?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/7f0375f9-7278-4427-a151-70ec39d85ba1?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4404)
Author
Owner

@bytaesu commented on GitHub (Sep 4, 2025):

Hi @himself65,
Could you check this out?

@bytaesu commented on GitHub (Sep 4, 2025): Hi @himself65, Could you check this out?
Author
Owner

@himself65 commented on GitHub (Sep 4, 2025):

Ok it’s the bundler issue. I know how to fix. Let me do that

@himself65 commented on GitHub (Sep 4, 2025): Ok it’s the bundler issue. I know how to fix. Let me do that
Author
Owner

@bytaesu commented on GitHub (Sep 4, 2025):

Ok it’s the bundler issue. I know how to fix. Let me do that

Glad to see such an active maintainer like you on Better Auth. Thanks!

@bytaesu commented on GitHub (Sep 4, 2025): > Ok it’s the bundler issue. I know how to fix. Let me do that Glad to see such an active maintainer like you on Better Auth. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1835