[PR #3679] [MERGED] fix(client): prevent proxy from exposing then property to avoid promise-like behavior (#3657) #30553

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3679
Author: @Aditya-ingole21
Created: 7/28/2025
Status: Merged
Merged: 8/19/2025
Merged by: @himself65

Base: mainHead: fix/vitest-thenable-trap


📝 Commits (10+)

  • 18f442b fix(client): prevent proxy from exposing 'then' property to avoid promise-like behavior
  • 514ab21 Merge branch 'main' into fix/vitest-thenable-trap
  • 25385f8 add catch and finally
  • bbe89db chore: update test
  • d9cf7e7 chore: changeset
  • fcf68ba Merge branch 'main' into fix/vitest-thenable-trap
  • 050fce5 Merge branch 'main' into fix/vitest-thenable-trap
  • febf7d8 Merge branch 'main' into fix/vitest-thenable-trap
  • 7cfa7e2 fix: remove .changeset
  • ed9f3a1 revert

📊 Changes

2 files changed (+17 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/client/client.test.ts (+14 -0)
📝 packages/better-auth/src/client/proxy.ts (+3 -0)

📄 Description

Summary
Fixes #3657

The client proxy was unintentionally exposing a then property, which caused Vitest to treat the proxy as a Promise.
This resulted in unexpected test behavior.

Changes Made

  • Updated proxy implementation to ensure .then is not exposed

  • Added a regression test:

    it("should not expose a 'then' property on the proxy", async () => {
    const proxy = (client as any).test;
    expect(proxy.then).toBeUndefined();
    });

  • Removed unused test artifact (state.txt)

Why
This fix ensures the proxy cannot be mistaken for a Promise-like object,
preventing runtime and test inconsistencies.

Checklist

  • Bug fix implemented
  • New test added and passing

Summary by cubic

Fixed the client proxy so it no longer exposes a then property, preventing it from being treated as a Promise and avoiding unexpected test behavior.

  • Bug Fixes
    • Updated the proxy to return undefined for then.
    • Added a regression test to ensure then is not exposed.
    • Removed an unused test artifact.

🔄 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/3679 **Author:** [@Aditya-ingole21](https://github.com/Aditya-ingole21) **Created:** 7/28/2025 **Status:** ✅ Merged **Merged:** 8/19/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `main` ← **Head:** `fix/vitest-thenable-trap` --- ### 📝 Commits (10+) - [`18f442b`](https://github.com/better-auth/better-auth/commit/18f442b08207c9861b9eb6fb356efb0efc7d0f54) fix(client): prevent proxy from exposing 'then' property to avoid promise-like behavior - [`514ab21`](https://github.com/better-auth/better-auth/commit/514ab21b389db1f1bb357540d9effc85a18fbfd9) Merge branch 'main' into fix/vitest-thenable-trap - [`25385f8`](https://github.com/better-auth/better-auth/commit/25385f841369e4d9000513a6eb1c2b4ad6815b4f) add catch and finally - [`bbe89db`](https://github.com/better-auth/better-auth/commit/bbe89db89255ecbc31085e8a02e94d3dcad869f4) chore: update test - [`d9cf7e7`](https://github.com/better-auth/better-auth/commit/d9cf7e78d925ef9460ae88699b96422eb142d708) chore: changeset - [`fcf68ba`](https://github.com/better-auth/better-auth/commit/fcf68bac8ad244bd877b85a3432e142292639803) Merge branch 'main' into fix/vitest-thenable-trap - [`050fce5`](https://github.com/better-auth/better-auth/commit/050fce553c454a594c43693133dee3913c0a5e98) Merge branch 'main' into fix/vitest-thenable-trap - [`febf7d8`](https://github.com/better-auth/better-auth/commit/febf7d826045cc7b9a2d6de19257d743a58e2de9) Merge branch 'main' into fix/vitest-thenable-trap - [`7cfa7e2`](https://github.com/better-auth/better-auth/commit/7cfa7e2ccb8b8e783f24129db5895e5ca807771c) fix: remove .changeset - [`ed9f3a1`](https://github.com/better-auth/better-auth/commit/ed9f3a14f135d5b9fdbf1e150bd80413996db609) revert ### 📊 Changes **2 files changed** (+17 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/client.test.ts` (+14 -0) 📝 `packages/better-auth/src/client/proxy.ts` (+3 -0) </details> ### 📄 Description Summary Fixes #3657 The client proxy was unintentionally exposing a `then` property, which caused Vitest to treat the proxy as a Promise. This resulted in unexpected test behavior. Changes Made - Updated proxy implementation to ensure `.then` is not exposed - Added a regression test: it("should not expose a 'then' property on the proxy", async () => { const proxy = (client as any).test; expect(proxy.then).toBeUndefined(); }); - Removed unused test artifact (state.txt) Why This fix ensures the proxy cannot be mistaken for a Promise-like object, preventing runtime and test inconsistencies. Checklist - Bug fix implemented - New test added and passing <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed the client proxy so it no longer exposes a `then` property, preventing it from being treated as a Promise and avoiding unexpected test behavior. - **Bug Fixes** - Updated the proxy to return `undefined` for `then`. - Added a regression test to ensure `then` is not exposed. - Removed an unused test artifact. <!-- 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:36:26 -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#30553