Skip to content

Remove some statefulness from SSR stack handling#13155

Closed
gaearon wants to merge 2 commits intofacebook:masterfrom
gaearon:ssr-stacks
Closed

Remove some statefulness from SSR stack handling#13155
gaearon wants to merge 2 commits intofacebook:masterfrom
gaearon:ssr-stacks

Conversation

@gaearon
Copy link
Copy Markdown
Collaborator

@gaearon gaearon commented Jul 6, 2018

I started looking into fixing #10188 (which I think would be good before we do #13149), but it was really hard to understand what's going on in the SSR stack handling because of the unnecessary mutable state.

I added a detailed test to capture regressions to this part of the code, and then refactored it to remove the stateful currentDebugElementStack. We could already get it from the frame if we only passed it down, which is what I’m doing. This also makes the !== null check motivated in this comment unnecessary because even if it's re-entrant, we're going to access the right reference from the argument.

In a follow up, I'll try to fix reentrancy for SSR (and add test coverage around that).

@pull-bot
Copy link
Copy Markdown

pull-bot commented Jul 6, 2018

Details of bundled changes.

Comparing: 96d38d1...c599f59

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-server.browser.development.js -0.2% -0.2% 99.26 KB 99.03 KB 26.19 KB 26.15 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% 🔺+0.1% 14.81 KB 14.82 KB 5.69 KB 5.69 KB UMD_PROD
react-dom-server.browser.development.js -0.2% -0.2% 95.39 KB 95.15 KB 25.24 KB 25.2 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% 🔺+0.1% 14.71 KB 14.71 KB 5.62 KB 5.63 KB NODE_PROD
react-dom-server.node.development.js -0.2% -0.2% 97.31 KB 97.07 KB 25.78 KB 25.74 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 🔺+0.1% 15.51 KB 15.52 KB 5.92 KB 5.93 KB NODE_PROD
ReactDOMServer-dev.js -0.2% -0.2% 96.44 KB 96.25 KB 24.79 KB 24.74 KB FB_WWW_DEV
ReactDOMServer-prod.js 🔺+1.2% 🔺+0.7% 31.97 KB 32.35 KB 7.78 KB 7.83 KB FB_WWW_PROD

Generated by 🚫 dangerJS

gaearon added 2 commits July 9, 2018 13:58
I found it quite difficult to understand what's going on because of multiple "stacks": this.frames, a pointer to the "current" this.frames, and a currentDebugElementStack which is being kept in sync with it.

This refactors it to be an argument instead since the only place where we use it is down the (haha) call stack and we don't actually need it to be stateful.

Note this doesn't change the behavior and still has existing issues with re-entrancy.
@gaearon
Copy link
Copy Markdown
Collaborator Author

gaearon commented Jul 11, 2018

I'll do #13181 instead

@gaearon gaearon closed this Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants