-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit 379670d
fix(core): make sure queries revert synchronously (#9601)
the switch from the callback approach to async/await with catch was necessary to be able to transform errors into revert-state data for imperative query calls; however, this was a change in behavior because catch in async/await doesn't happen immediately - it runs in the next microtask. That opened up an opportunity for a slight race condition if we re-start a fetch in-between. And who does that? Of course, React Strict Mode.
This PR moves the actual state reverting back to a callback (so it happens synchronously), while still keeping the try/catch refactoring merely to transform the promise and the usual error handling1 parent 428c19f commit 379670d
File tree
3 files changed
+64
-9
lines changed- packages/query-core/src
- __tests__
3 files changed
+64
-9
lines changedLines changed: 50 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1192 | 1192 |
| |
1193 | 1193 |
| |
1194 | 1194 |
| |
1195 | + | ||
1196 | + | ||
1197 | + | ||
1198 | + | ||
1199 | + | ||
1200 | + | ||
1201 | + | ||
1202 | + | ||
1203 | + | ||
1204 | + | ||
1205 | + | ||
1206 | + | ||
1207 | + | ||
1208 | + | ||
1209 | + | ||
1210 | + | ||
1211 | + | ||
1212 | + | ||
1213 | + | ||
1214 | + | ||
1215 | + | ||
1216 | + | ||
1217 | + | ||
1218 | + | ||
1219 | + | ||
1220 | + | ||
1221 | + | ||
1222 | + | ||
1223 | + | ||
1224 | + | ||
1225 | + | ||
1226 | + | ||
1227 | + | ||
1228 | + | ||
1229 | + | ||
1230 | + | ||
1231 | + | ||
1232 | + | ||
1233 | + | ||
1234 | + | ||
1235 | + | ||
1236 | + | ||
1237 | + | ||
1238 | + | ||
1239 | + | ||
1240 | + | ||
1241 | + | ||
1242 | + | ||
1243 | + | ||
1244 | + | ||
1195 | 1245 |
|
Lines changed: 10 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
507 | 507 |
| |
508 | 508 |
| |
509 | 509 |
| |
510 | - | ||
510 | + | ||
511 | + | ||
512 | + | ||
513 | + | ||
514 | + | ||
515 | + | ||
516 | + | ||
517 | + | ||
518 | + | ||
511 | 519 |
| |
512 | 520 |
| |
513 | 521 |
| |
| |||
550 | 558 |
| |
551 | 559 |
| |
552 | 560 |
| |
553 | - | ||
561 | + | ||
554 | 562 |
| |
555 | 563 |
| |
556 | - | ||
557 | - | ||
558 | - | ||
559 | - | ||
560 | 564 |
| |
561 | 565 |
| |
562 | 566 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
13 | - | ||
13 | + | ||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
| |||
86 | 86 |
| |
87 | 87 |
| |
88 | 88 |
| |
89 | - | ||
89 | + | ||
90 | + | ||
90 | 91 |
| |
91 | - | ||
92 | + | ||
92 | 93 |
| |
93 | 94 |
| |
94 | 95 |
| |
|
0 commit comments