[PR #7013] [CLOSED] fix(client): signal race condition fix in the createDynamicPathProxy function #32623

Closed
opened 2026-04-17 23:23:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7013
Author: @mayur9210
Created: 12/27/2025
Status: Closed

Base: canaryHead: signal-race-condition


📝 Commits (4)

  • 9f7a62c fix(client): signal race conditions and tests for createDynamicPathProxy to fix signal race conditions
  • 4fd23c5 fix(tests): enhance signal race condition handling and deduplicate signals in createDynamicPathProxy
  • 3c701f2 Merge branch 'canary' into signal-race-condition
  • 1b740d6 fix(proxy): improve signal toggling by removing unnecessary microtask queue

📊 Changes

2 files changed (+255 additions, -11 deletions)

View changed files

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

📄 Description

Tests for the signal race condition fix in the createDynamicPathProxy function and refactors the signal toggling logic to use the microtask queue for improved async coordination. The changes ensure that signal updates are reliable, prevent race conditions, and improve the robustness of the proxy client.

Signal update logic:

  • Refactored signal toggling in createDynamicPathProxy to use queueMicrotask instead of setTimeout, ensuring atomic updates and eliminating race conditions during async operations.

Testing improvements:

  • Added a new test suite proxy.test.ts to validate signal toggling behavior, concurrent API calls, disabling signal updates, handling missing signals, listener matching, and custom callbacks in createDynamicPathProxy.

Summary by cubic

Fixed signal race conditions in createDynamicPathProxy by toggling atom signals immediately in onSuccess with deduplication. Added tests for concurrent calls, disabled/missing signals, listener matching, custom onSuccess, and deduplicated signals.

  • Bug Fixes
    • Removed microtask/setTimeout scheduling and toggle signals synchronously to avoid races.
    • Deduplicated toggles when multiple listeners target the same signal.
    • Added safety for missing atoms and only toggle when signal.set exists.

Written for commit 1b740d6414. 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/7013 **Author:** [@mayur9210](https://github.com/mayur9210) **Created:** 12/27/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `signal-race-condition` --- ### 📝 Commits (4) - [`9f7a62c`](https://github.com/better-auth/better-auth/commit/9f7a62cd955e51e8e55ac8013dcc698c19b43bf5) fix(client): signal race conditions and tests for createDynamicPathProxy to fix signal race conditions - [`4fd23c5`](https://github.com/better-auth/better-auth/commit/4fd23c554b4500c411682638405eeaf0d7c76b98) fix(tests): enhance signal race condition handling and deduplicate signals in createDynamicPathProxy - [`3c701f2`](https://github.com/better-auth/better-auth/commit/3c701f2991b4b7055b027d0b5608e93b0efd5e07) Merge branch 'canary' into signal-race-condition - [`1b740d6`](https://github.com/better-auth/better-auth/commit/1b740d64142b589d64fd015e8218b9c8e6079d43) fix(proxy): improve signal toggling by removing unnecessary microtask queue ### 📊 Changes **2 files changed** (+255 additions, -11 deletions) <details> <summary>View changed files</summary> ➕ `packages/better-auth/src/client/proxy.test.ts` (+244 -0) 📝 `packages/better-auth/src/client/proxy.ts` (+11 -11) </details> ### 📄 Description Tests for the signal race condition fix in the `createDynamicPathProxy` function and refactors the signal toggling logic to use the microtask queue for improved async coordination. The changes ensure that signal updates are reliable, prevent race conditions, and improve the robustness of the proxy client. **Signal update logic:** * Refactored signal toggling in `createDynamicPathProxy` to use `queueMicrotask` instead of `setTimeout`, ensuring atomic updates and eliminating race conditions during async operations. **Testing improvements:** * Added a new test suite `proxy.test.ts` to validate signal toggling behavior, concurrent API calls, disabling signal updates, handling missing signals, listener matching, and custom callbacks in `createDynamicPathProxy`. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed signal race conditions in createDynamicPathProxy by toggling atom signals immediately in onSuccess with deduplication. Added tests for concurrent calls, disabled/missing signals, listener matching, custom onSuccess, and deduplicated signals. - **Bug Fixes** - Removed microtask/setTimeout scheduling and toggle signals synchronously to avoid races. - Deduplicated toggles when multiple listeners target the same signal. - Added safety for missing atoms and only toggle when signal.set exists. <sup>Written for commit 1b740d64142b589d64fd015e8218b9c8e6079d43. 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-04-17 23:23:19 -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#32623