[PR #4094] [MERGED] fix: move stack check into inner function #30786

Closed
opened 2026-04-17 21:48:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4094
Author: @himself65
Created: 8/19/2025
Status: Merged
Merged: 8/20/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/08/19/inject


📝 Commits (2)

  • 693f795 fix: move stack check into inner function
  • e7d2984 Merge branch 'canary' into himself65/2025/08/19/inject

📊 Changes

1 file changed (+24 additions, -30 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.ts (+24 -30)

📄 Description

Fixes: https://github.com/better-auth/better-auth/pull/4091#discussion_r2286623964


Summary by cubic

Moved APIError stack handling into runBeforeHooks and runAfterHooks, using InternalContext with a logger to scope stack updates to hook errors only. This keeps debug stacks intact and avoids catching unrelated endpoint errors.

  • Bug Fixes
    • Handle APIError inside hook runners and set stack when debug; removed outer try/catch around hook calls.
    • Switched hook runner signatures to use InternalContext and added logger to context for safe access.
    • Preserves existing behavior for error responses and headers; only the stack handling scope changed.

🔄 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/4094 **Author:** [@himself65](https://github.com/himself65) **Created:** 8/19/2025 **Status:** ✅ Merged **Merged:** 8/20/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/08/19/inject` --- ### 📝 Commits (2) - [`693f795`](https://github.com/better-auth/better-auth/commit/693f7957b78256e8904a6c364a67415e11fb2436) fix: move stack check into inner function - [`e7d2984`](https://github.com/better-auth/better-auth/commit/e7d298497338f5130ce1f390eae6e70d4976d767) Merge branch 'canary' into himself65/2025/08/19/inject ### 📊 Changes **1 file changed** (+24 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+24 -30) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/pull/4091#discussion_r2286623964 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Moved APIError stack handling into runBeforeHooks and runAfterHooks, using InternalContext with a logger to scope stack updates to hook errors only. This keeps debug stacks intact and avoids catching unrelated endpoint errors. - **Bug Fixes** - Handle APIError inside hook runners and set stack when debug; removed outer try/catch around hook calls. - Switched hook runner signatures to use InternalContext and added logger to context for safe access. - Preserves existing behavior for error responses and headers; only the stack handling scope changed. <!-- 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 21:48:51 -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#30786