Commit 906aa2b
fix: don't swallow createAsyncThunk aborts that happen before pending (#5314)
When a thunk's `AbortController` was aborted before the `pending` action was
dispatched - either because an already-aborted external `signal` was passed,
or because `abort()` was called while an async `condition` was still pending -
the resulting error was reported as a `ConditionError` with the message
"Aborted due to condition callback returning false."
Because `meta.condition` was then `true`, the `rejected` action was skipped by
default (unless `dispatchConditionRejection` was set), so the abort was
silently swallowed and the error was mislabeled even though no `condition`
callback ever returned `false`.
This was inconsistent with aborting the same signal moments later (once the
thunk is running), which correctly produces a `rejected` action with an
`AbortError`, and it contradicted the documented "Canceling While Running"
behavior.
The condition-check now only throws a `ConditionError` when `condition`
actually returns `false`. If the controller was aborted, it instead throws an
`AbortError` carrying the real abort reason, so the abort is reported and
dispatched consistently regardless of timing.
Co-authored-by: Arya Emami <aryaemami59@yahoo.com>1 parent 970895a commit 906aa2b
2 files changed
Lines changed: 71 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
639 | | - | |
| 639 | + | |
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
646 | 658 | | |
647 | 659 | | |
648 | 660 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
| 623 | + | |
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| 630 | + | |
630 | 631 | | |
631 | 632 | | |
632 | | - | |
633 | | - | |
| 633 | + | |
| 634 | + | |
634 | 635 | | |
635 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
636 | 647 | | |
637 | 648 | | |
638 | 649 | | |
| |||
1028 | 1039 | | |
1029 | 1040 | | |
1030 | 1041 | | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
1031 | 1073 | | |
1032 | | - | |
| 1074 | + | |
1033 | 1075 | | |
1034 | 1076 | | |
1035 | 1077 | | |
1036 | 1078 | | |
1037 | 1079 | | |
| 1080 | + | |
1038 | 1081 | | |
1039 | 1082 | | |
1040 | 1083 | | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
1041 | 1087 | | |
1042 | | - | |
| 1088 | + | |
1043 | 1089 | | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
1044 | 1096 | | |
1045 | 1097 | | |
0 commit comments