Skip to content

Commit 749ddba

Browse files
committed
Preserve status code on clientAction throw data() results
1 parent 937acc5 commit 749ddba

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/late-hats-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Preserve status code if a `clientAction` throws a `data()` result in framework mode

packages/react-router/lib/dom/ssr/single-fetch.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22

33
import { decode } from "../../../vendor/turbo-stream-v2/turbo-stream";
44
import type { Router as DataRouter } from "../../router/router";
5-
import { isResponse } from "../../router/router";
5+
import { isDataWithResponseInit, isResponse } from "../../router/router";
66
import type {
77
DataStrategyFunction,
88
DataStrategyFunctionArgs,
@@ -289,7 +289,11 @@ async function singleFetchActionStrategy(
289289
return result;
290290
});
291291

292-
if (isResponse(result.result) || isRouteErrorResponse(result.result)) {
292+
if (
293+
isResponse(result.result) ||
294+
isRouteErrorResponse(result.result) ||
295+
isDataWithResponseInit(result.result)
296+
) {
293297
return { [actionMatch.route.id]: result };
294298
}
295299

0 commit comments

Comments
 (0)