Commit 53d76f9
committed
Improve cyclic thenable detection in ReactFlightReplyServer (facebook#35369)
## Summary
This PR improves cyclic thenable detection in
`ReactFlightReplyServer.js`. Fixes facebook#35368.
The previous fix only detected direct self-references (`inspectedValue
=== chunk`) and relied on the `cycleProtection` counter to eventually
bail out of longer cycles. This change keeps the existing
MAX_THENABLE_CYCLE_DEPTH ($1000$) `cycleProtection` cap as a hard
guardrail and adds a visited set so that we can detect self-cycles and
multi-node cycles as soon as any `ReactPromise` is revisited and while
still bounding the amount of work we do for deep acyclic chains via
`cycleProtection`.
## How did you test this change?
- Ran the existing test suite for the server renderer:
```bash
yarn test react-server
yarn test --prod react-server
yarn flow dom-node
yarn linc
```
---------
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
DiffTrain build for [b731fe2](facebook@b731fe2)1 parent 10b8e71 commit 53d76f9
File tree
34 files changed
+130
-258
lines changed- compiled/facebook-www
34 files changed
+130
-258
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1499 | 1499 | | |
1500 | 1500 | | |
1501 | 1501 | | |
1502 | | - | |
| 1502 | + | |
1503 | 1503 | | |
1504 | 1504 | | |
1505 | 1505 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1499 | 1499 | | |
1500 | 1500 | | |
1501 | 1501 | | |
1502 | | - | |
| 1502 | + | |
1503 | 1503 | | |
1504 | 1504 | | |
1505 | 1505 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20468 | 20468 | | |
20469 | 20469 | | |
20470 | 20470 | | |
20471 | | - | |
| 20471 | + | |
20472 | 20472 | | |
20473 | 20473 | | |
20474 | | - | |
| 20474 | + | |
20475 | 20475 | | |
20476 | 20476 | | |
20477 | 20477 | | |
| |||
20506 | 20506 | | |
20507 | 20507 | | |
20508 | 20508 | | |
20509 | | - | |
| 20509 | + | |
20510 | 20510 | | |
20511 | 20511 | | |
20512 | 20512 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20239 | 20239 | | |
20240 | 20240 | | |
20241 | 20241 | | |
20242 | | - | |
| 20242 | + | |
20243 | 20243 | | |
20244 | 20244 | | |
20245 | | - | |
| 20245 | + | |
20246 | 20246 | | |
20247 | 20247 | | |
20248 | 20248 | | |
| |||
20277 | 20277 | | |
20278 | 20278 | | |
20279 | 20279 | | |
20280 | | - | |
| 20280 | + | |
20281 | 20281 | | |
20282 | 20282 | | |
20283 | 20283 | | |
| |||
0 commit comments