Commit aec5759
[Fizz] Send errors down to client (#24551)
* use return from onError
* export getSuspenseInstanceFallbackError
* stringToChunk
* return string from onError in downstream type signatures
* 1 more type
* support encoding errors in html stream and escape user input
This commit adds another way to get errors to the suspense instance by encoding them as dataset properties of a template element at the head of the boundary. Previously if there was an error before the boundary flushed there was no way to stream the error to the client because there would never be a client render instruction.
Additionally the error is sent in 3 parts
1) error hash - this is always sent (dev or prod) if one is provided
2) error message - Dev only
3) error component stack - Dev only, this now captures the stack at the point of error
Another item addressed in this commit is the escaping of potentially unsafe data. all error components are escaped as test for browers when written into the html and as javascript strings when written into a client render instruction.
* nits
Co-authored-by: Marco Salazar <salazarm@fb.com>1 parent a276638 commit aec5759
File tree
17 files changed
+768
-77
lines changed- packages
- react-dom/src
- __tests__
- client
- server
- react-native-renderer/src/server
- react-noop-renderer/src
- react-reconciler/src
- forks
- react-server-dom-relay/src/__tests__
- react-server/src
- scripts/error-codes
17 files changed
+768
-77
lines changedLines changed: 418 additions & 39 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
204 | 210 | | |
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
210 | 220 | | |
211 | 221 | | |
212 | 222 | | |
| |||
223 | 233 | | |
224 | 234 | | |
225 | 235 | | |
| 236 | + | |
226 | 237 | | |
227 | 238 | | |
228 | 239 | | |
229 | 240 | | |
230 | 241 | | |
231 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
232 | 248 | | |
233 | 249 | | |
234 | 250 | | |
| |||
239 | 255 | | |
240 | 256 | | |
241 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
242 | 262 | | |
243 | 263 | | |
244 | 264 | | |
| |||
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
| |||
289 | 292 | | |
290 | 293 | | |
291 | 294 | | |
| 295 | + | |
292 | 296 | | |
293 | 297 | | |
294 | 298 | | |
| |||
298 | 302 | | |
299 | 303 | | |
300 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
301 | 308 | | |
302 | 309 | | |
303 | 310 | | |
| |||
314 | 321 | | |
315 | 322 | | |
316 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
317 | 327 | | |
318 | 328 | | |
319 | 329 | | |
| |||
322 | 332 | | |
323 | 333 | | |
324 | 334 | | |
| 335 | + | |
325 | 336 | | |
326 | 337 | | |
327 | 338 | | |
| |||
333 | 344 | | |
334 | 345 | | |
335 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
336 | 350 | | |
337 | 351 | | |
338 | 352 | | |
| |||
349 | 363 | | |
350 | 364 | | |
351 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
352 | 371 | | |
353 | 372 | | |
354 | 373 | | |
| |||
552 | 571 | | |
553 | 572 | | |
554 | 573 | | |
| 574 | + | |
555 | 575 | | |
556 | 576 | | |
557 | 577 | | |
| |||
560 | 580 | | |
561 | 581 | | |
562 | 582 | | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
563 | 586 | | |
564 | 587 | | |
565 | 588 | | |
| |||
579 | 602 | | |
580 | 603 | | |
581 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
582 | 608 | | |
583 | 609 | | |
584 | 610 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
729 | 729 | | |
730 | 730 | | |
731 | 731 | | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
732 | 756 | | |
733 | 757 | | |
734 | 758 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
Lines changed: 106 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1526 | 1526 | | |
1527 | 1527 | | |
1528 | 1528 | | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
1529 | 1542 | | |
1530 | 1543 | | |
1531 | 1544 | | |
| |||
1563 | 1576 | | |
1564 | 1577 | | |
1565 | 1578 | | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
1566 | 1582 | | |
1567 | | - | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
1568 | 1616 | | |
1569 | 1617 | | |
1570 | 1618 | | |
| |||
1724 | 1772 | | |
1725 | 1773 | | |
1726 | 1774 | | |
1727 | | - | |
| 1775 | + | |
1728 | 1776 | | |
1729 | 1777 | | |
1730 | 1778 | | |
| |||
1736 | 1784 | | |
1737 | 1785 | | |
1738 | 1786 | | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
1739 | 1792 | | |
1740 | 1793 | | |
1741 | 1794 | | |
| |||
1823 | 1876 | | |
1824 | 1877 | | |
1825 | 1878 | | |
1826 | | - | |
| 1879 | + | |
1827 | 1880 | | |
1828 | 1881 | | |
1829 | 1882 | | |
| |||
1896 | 1949 | | |
1897 | 1950 | | |
1898 | 1951 | | |
1899 | | - | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
1900 | 1955 | | |
1901 | 1956 | | |
1902 | 1957 | | |
1903 | 1958 | | |
1904 | 1959 | | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
1905 | 1963 | | |
1906 | 1964 | | |
1907 | 1965 | | |
| |||
1920 | 1978 | | |
1921 | 1979 | | |
1922 | 1980 | | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
1923 | 2003 | | |
1924 | 2004 | | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
| |||
0 commit comments