[PR #6630] [MERGED] chore: import async_hooks per conditional exports #6792

Closed
opened 2026-03-13 13:11:53 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6630
Author: @himself65
Created: 12/9/2025
Status: Merged
Merged: 12/10/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/12/09/split


📝 Commits (4)

📊 Changes

8 files changed (+60 additions, -48 deletions)

View changed files

📝 packages/core/package.json (+6 -0)
packages/core/src/async_hooks/convex.spec.ts (+0 -12)
📝 packages/core/src/async_hooks/index.ts (+0 -30)
packages/core/src/async_hooks/pure.index.ts (+46 -0)
📝 packages/core/src/context/endpoint-context.ts (+2 -2)
📝 packages/core/src/context/request-state.ts (+2 -2)
📝 packages/core/src/context/transaction.ts (+2 -2)
📝 packages/core/tsdown.config.ts (+2 -0)

📄 Description

For: https://github.com/better-auth/better-auth/pull/6622#discussion_r2600988672


Summary by cubic

Remove node:async_hooks usage from non-Node builds. Route edge and browser runtimes (incl. Convex) to a pure fallback so they work without Node APIs.

  • Bug Fixes
    • Added async_hooks/pure.index.ts: uses globalThis.AsyncLocalStorage when available, otherwise a lightweight polyfill. No node:async_hooks import.
    • Updated package.json export conditions: edge/browser → pure.index.mjs; node/workerd/deno/bun/default → index.mjs.
    • Switched internal imports to "@better-auth/core/async_hooks".
    • Removed Convex-specific test and simplified async_hooks/index.ts; included new file in build config.

Written for commit 74e1d4f175. Summary will update automatically on new commits.


🔄 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/6630 **Author:** [@himself65](https://github.com/himself65) **Created:** 12/9/2025 **Status:** ✅ Merged **Merged:** 12/10/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/12/09/split` --- ### 📝 Commits (4) - [`973c4e2`](https://github.com/better-auth/better-auth/commit/973c4e230f1a3815e848a7c78668939a29ac1e05) chore: do not import async_hooks in default export condition - [`c99a999`](https://github.com/better-auth/better-auth/commit/c99a999879aaf3cc1690d8e7401dca97cee49714) fix: import - [`bcb4d03`](https://github.com/better-auth/better-auth/commit/bcb4d03ea6c92006048fe793e91baf2fe8360f3d) fix: import - [`74e1d4f`](https://github.com/better-auth/better-auth/commit/74e1d4f17576857d2f5c8d72f499f9bd3026c174) fix: browser ### 📊 Changes **8 files changed** (+60 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/package.json` (+6 -0) ➖ `packages/core/src/async_hooks/convex.spec.ts` (+0 -12) 📝 `packages/core/src/async_hooks/index.ts` (+0 -30) ➕ `packages/core/src/async_hooks/pure.index.ts` (+46 -0) 📝 `packages/core/src/context/endpoint-context.ts` (+2 -2) 📝 `packages/core/src/context/request-state.ts` (+2 -2) 📝 `packages/core/src/context/transaction.ts` (+2 -2) 📝 `packages/core/tsdown.config.ts` (+2 -0) </details> ### 📄 Description For: https://github.com/better-auth/better-auth/pull/6622#discussion_r2600988672 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Remove node:async_hooks usage from non-Node builds. Route edge and browser runtimes (incl. Convex) to a pure fallback so they work without Node APIs. - **Bug Fixes** - Added async_hooks/pure.index.ts: uses globalThis.AsyncLocalStorage when available, otherwise a lightweight polyfill. No node:async_hooks import. - Updated package.json export conditions: edge/browser → pure.index.mjs; node/workerd/deno/bun/default → index.mjs. - Switched internal imports to "@better-auth/core/async_hooks". - Removed Convex-specific test and simplified async_hooks/index.ts; included new file in build config. <sup>Written for commit 74e1d4f17576857d2f5c8d72f499f9bd3026c174. Summary will update automatically on new commits.</sup> <!-- 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-03-13 13:11:53 -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#6792