[PR #3783] [MERGED] fix: await ctx in middleware #5000

Closed
opened 2026-03-13 12:06:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3783
Author: @himself65
Created: 8/4/2025
Status: Merged
Merged: 8/4/2025
Merged by: @Bekacru

Base: canaryHead: himself65/2025/08/04/ctx


📝 Commits (3)

📊 Changes

3 files changed (+61 additions, -1 deletions)

View changed files

.changeset/tidy-impalas-fail.md (+5 -0)
packages/better-auth/src/api/index.test.ts (+54 -0)
📝 packages/better-auth/src/api/index.ts (+2 -1)

📄 Description

ctx could be a promise in some cases


Summary by cubic

Fixed middleware to await the context if it is a promise, ensuring correct context merging before passing to plugins.

  • Bug Fixes
  • Updated middleware to handle promise-based contexts.
  • Added tests to verify correct context handling.

🔄 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/3783 **Author:** [@himself65](https://github.com/himself65) **Created:** 8/4/2025 **Status:** ✅ Merged **Merged:** 8/4/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `himself65/2025/08/04/ctx` --- ### 📝 Commits (3) - [`5110894`](https://github.com/better-auth/better-auth/commit/511089463c3968deff4d2eef1d3b91cd506ed55b) fix: await ctx in middleware - [`90cdf31`](https://github.com/better-auth/better-auth/commit/90cdf31b5b04518cdf233731e5e913a4eab144bc) fix: lint - [`6452511`](https://github.com/better-auth/better-auth/commit/64525115d7c37796dfbd9dc46233715c894e15a7) Create tidy-impalas-fail.md ### 📊 Changes **3 files changed** (+61 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/tidy-impalas-fail.md` (+5 -0) ➕ `packages/better-auth/src/api/index.test.ts` (+54 -0) 📝 `packages/better-auth/src/api/index.ts` (+2 -1) </details> ### 📄 Description `ctx` could be a promise in some cases <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed middleware to await the context if it is a promise, ensuring correct context merging before passing to plugins. - **Bug Fixes** - Updated middleware to handle promise-based contexts. - Added tests to verify correct context handling. <!-- 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 12:06:55 -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#5000