Commit 056c57b
authored
fix: only set request phase to "action" when actually running an action (#76993)
When running a server action, we want `requestStore.phase` to be set to `'action'`, because it makes `cookies()` mutable. However we were doing this in a pretty coarse-grained manner -- it was set at the beginning of `handleAction`, but wasn't always properly cleaned up in case of early returns that don't render anything (e.g. `{ type: 'not-found' }`). This PR fixes that -- we only set the phase to `'action'` while the action is running, and immediately switch it to `'render'` when it settles.
Incidentally, early 'not-found' returns from `handleAction` are currently bugged (see #77012 for more context + fix), so we were also accidentally allowing mutatating cookies while rendering a response to an unrecognized action, which should be a 404, but is currently a 200 + a page render. but that's such a niche edge case that it's not really relevant to real usage.1 parent 366b725 commit 056c57b
1 file changed
Lines changed: 29 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
514 | | - | |
515 | 513 | | |
516 | 514 | | |
517 | 515 | | |
518 | | - | |
519 | | - | |
520 | 516 | | |
521 | 517 | | |
522 | 518 | | |
| |||
674 | 670 | | |
675 | 671 | | |
676 | 672 | | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
681 | 683 | | |
682 | 684 | | |
683 | 685 | | |
684 | 686 | | |
685 | 687 | | |
686 | 688 | | |
687 | | - | |
688 | | - | |
689 | 689 | | |
690 | 690 | | |
691 | 691 | | |
| |||
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
836 | 842 | | |
837 | 843 | | |
838 | 844 | | |
839 | 845 | | |
840 | 846 | | |
841 | 847 | | |
842 | | - | |
843 | | - | |
844 | 848 | | |
845 | 849 | | |
846 | 850 | | |
| |||
917 | 921 | | |
918 | 922 | | |
919 | 923 | | |
920 | | - | |
921 | | - | |
922 | | - | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
923 | 933 | | |
924 | 934 | | |
925 | 935 | | |
| |||
1017 | 1027 | | |
1018 | 1028 | | |
1019 | 1029 | | |
1020 | | - | |
1021 | 1030 | | |
1022 | 1031 | | |
1023 | 1032 | | |
| |||
0 commit comments