fix(content): prevent forceUpdate in SSR#27440
Conversation
|
|
| } else if (this.cTop !== 0 || this.cBottom !== 0) { | ||
| this.cTop = this.cBottom = 0; | ||
| forceUpdate(this); | ||
| if (Build.isBrowser) { |
There was a problem hiding this comment.
And so I understand, this is to work around a stencil bug correct?
There was a problem hiding this comment.
This isn't a workaround per-say. The reported issues attached are resolved by this change.
I had some discussions with Tanner around if forceUpdate should internally account for this. It checks for build conditions to see if it updatable: https://github.com/ionic-team/stencil/blob/main/src/runtime/update-component.ts#L328-L342, but should likely also check if it is in a browser context. At this time, we don't have enough historic data to confidently determine if forceUpdate should only execute in the browser or not. He is leading that conversation with the team and we will re-sync on the outcomes (if we can remove this in a future update of Stencil).
The problem that was occurring is that the pre-rendering logic would attempt to mock ion-content DOM tree, but would call forceUpdate as part of the first render, resulting in an infinite loop.
There was a problem hiding this comment.
Thanks! Can we include this context in the comment too?
There was a problem hiding this comment.
Also if there's an open stencil issue it would be good to link to that in the comment
There was a problem hiding this comment.
Added some extra context + created a spike in JIRA for Stencil to track (and referenced it in the code comments).
liamdebeasi
left a comment
There was a problem hiding this comment.
Good to go once comments are addressed. thanks for the quick turnaround!
Issue number: Resolves #27411, stenciljs/core#2429, stenciljs/core#4076
What is the current behavior?
Rendering
<ion-content fullscreen="true">in an Angular Universal project will result in a javascript heap exception and the browser tab timing out.forceUpdateis not a compatible API with pre-rendering and results in calling itself indefinitely.What is the new behavior?
ion-contentto only callforceUpdateand related functionality when running in a browser environment.<ion-content fullscreen="true">is compatible with Angular UniversalDoes this introduce a breaking change?
Other information
Dev-build:
7.0.6-dev.11683653232.1ddc5840✅