[PR #4323] [MERGED] fix: leave error from fetch API as-is #5311

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

📋 Pull Request Information

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

Base: canaryHead: himself65/2025/08/30/throw


📝 Commits (2)

📊 Changes

2 files changed (+7 additions, -7 deletions)

View changed files

📝 packages/better-auth/src/client/config.ts (+1 -7)
📝 packages/better-auth/src/plugins/organization/client.test.ts (+6 -0)

📄 Description

Upstream: https://github.com/better-auth/better-auth/pull/4307#discussion_r2312160139

This might be a potential breaking change? Previously, we returned Response.error for all fetches, but we actually ignored the error for the user. So I think we should just leave things as-is

For example, if the server is an invalid domain or does not exist, it's not an HTTP-level error. So return Response.error is meaningless.


Summary by cubic

Removed the catch that returned Response.error in customFetchImpl and now use native fetch directly. Network errors will now reject instead of returning a synthetic Response, surfacing real failures and aligning with standard fetch behavior.

  • Migration
    • If you assumed a Response on failure, wrap calls in try/catch (or .catch) and handle rejected fetch errors instead of only checking response.ok.

🔄 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/4323 **Author:** [@himself65](https://github.com/himself65) **Created:** 8/31/2025 **Status:** ✅ Merged **Merged:** 8/31/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/08/30/throw` --- ### 📝 Commits (2) - [`5573c87`](https://github.com/better-auth/better-auth/commit/5573c87041f51f670cdb1e76b19b4137942d6e5e) fix: no error catch - [`9acf8b9`](https://github.com/better-auth/better-auth/commit/9acf8b928cd6f77b3d7a14d9407cca8f9a6bb168) test: fix ### 📊 Changes **2 files changed** (+7 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/config.ts` (+1 -7) 📝 `packages/better-auth/src/plugins/organization/client.test.ts` (+6 -0) </details> ### 📄 Description Upstream: https://github.com/better-auth/better-auth/pull/4307#discussion_r2312160139 This might be a potential breaking change? Previously, we returned `Response.error` for all fetches, but we actually ignored the error for the user. So I think we should just leave things as-is For example, if the server is an invalid domain or does not exist, it's not an HTTP-level error. So return `Response.error` is meaningless. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Removed the catch that returned Response.error in customFetchImpl and now use native fetch directly. Network errors will now reject instead of returning a synthetic Response, surfacing real failures and aligning with standard fetch behavior. - **Migration** - If you assumed a Response on failure, wrap calls in try/catch (or .catch) and handle rejected fetch errors instead of only checking response.ok. <!-- 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:18:09 -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#5311