-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ServerAction rejection reason (#63744)
Recently the serverActionReducer was updated to no longer use React's thenable type to carry resolution/rejection information. However the rejection reason was not updated so now when a server action fails we were rejecting with `undefined` rather than the rejected reason. This change updates the reject to use the rejection value. Closes NEXT-2943
- Loading branch information
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use server' | ||
|
||
export async function action() { | ||
return 'action result' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client' | ||
|
||
import { action } from './actions' | ||
|
||
export default function Page() { | ||
return ( | ||
<main> | ||
<p> | ||
This button will call a server action and pass something unserializable | ||
like a class instance. We expect this action to error with a reasonable | ||
message explaning what happened | ||
</p> | ||
<button | ||
id="submit" | ||
onClick={async () => { | ||
await action(new Foo()) | ||
}} | ||
> | ||
Submit | ||
</button> | ||
</main> | ||
) | ||
} | ||
|
||
class Foo {} |