Repository navigation
Commit b2c6d03
authored
fix(use-cache): match Next.js erroring searchParams in "use cache" pages (#4028)
* fix(use-cache): fail a read of searchParams.then inside "use cache", like Next.js
The erroring searchParams a public "use cache" page gets threw only when
`then` was called. Next.js's makeErroringSearchParamsForUseCache throws
when `then` is read, so a thenable check such as `typeof sp.then` fails
too. Use the observeThenRead hook added in #4002.
* fix(use-cache): keep page searchParams erroring after they escape "use cache"
Next.js's makeErroringSearchParamsForUseCache throws on every access.
vinext's replacement only threw inside the cache scope, so a value that
escaped the cache function read as an empty query afterwards.
* fix(use-cache): match Next.js for catch, finally and escaped access on page searchParams
Next.js binds catch and finally to the underlying promise, so they never
read `then` through the erroring proxy. Run observeThenRead only on a
read of `then`, and let an empty key list through, so catch, finally and
Object.keys settle as in Next.js.
An access after the value escapes the cache function now records the
invalid use on the request the value was made for, like Next.js's
`workStore.invalidDynamicUsageError ??= error`.
* fix(use-cache): port the erroring page searchParams proxy from Next.js
Use a dedicated get-only proxy like makeErroringSearchParamsForUseCache
instead of makeThenableParams, so `in`, Object.hasOwn and catch/finally
behave as in Next.js, and revert the thenable-params change. Make it inside
the cache scope and record an access on that scope and request, wherever
the value is read later.
* fix(use-cache): keep the first caught searchParams access on the cache scope
Like Next.js's workStore.invalidDynamicUsageError ??= error.
* fix(use-cache): fail a "use cache" that an escaped page searchParams is read in
Record the access on the active cache scope too, so a cache that catches
it can't store a fallback that a later request would reuse.
* fix(use-cache): record escaped searchParams access on the request context
Capture the unified request context, as throwIfInsideCacheScope records
on, instead of the headers shim state. Outside a request that was the
module fallback state, so an access leaked into later renders.1 parent 31317da commit b2c6d03
3 files changed
Lines changed: 288 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
782 | 783 | | |
783 | 784 | | |
784 | 785 | | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | 786 | | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
791 | 793 | | |
792 | 794 | | |
793 | 795 | | |
794 | 796 | | |
795 | 797 | | |
796 | 798 | | |
797 | | - | |
| 799 | + | |
798 | 800 | | |
799 | 801 | | |
800 | 802 | | |
| |||
816 | 818 | | |
817 | 819 | | |
818 | 820 | | |
819 | | - | |
| 821 | + | |
820 | 822 | | |
821 | 823 | | |
822 | 824 | | |
| |||
826 | 828 | | |
827 | 829 | | |
828 | 830 | | |
829 | | - | |
| 831 | + | |
830 | 832 | | |
831 | 833 | | |
832 | 834 | | |
| |||
879 | 881 | | |
880 | 882 | | |
881 | 883 | | |
882 | | - | |
| 884 | + | |
883 | 885 | | |
884 | 886 | | |
885 | 887 | | |
| |||
1464 | 1466 | | |
1465 | 1467 | | |
1466 | 1468 | | |
1467 | | - | |
1468 | | - | |
1469 | | - | |
1470 | | - | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
1471 | 1472 | | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
1480 | | - | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
1481 | 1529 | | |
1482 | 1530 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
181 | 193 | | |
182 | 194 | | |
183 | 195 | | |
| |||
240 | 252 | | |
241 | 253 | | |
242 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
243 | 264 | | |
244 | 265 | | |
245 | 266 | | |
| |||
249 | 270 | | |
250 | 271 | | |
251 | 272 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
| 273 | + | |
257 | 274 | | |
258 | 275 | | |
259 | 276 | | |
| |||
0 commit comments