-
Notifications
You must be signed in to change notification settings - Fork 1.3k
memory leak of mapPropsStream at server side #328
Comments
Found a related issue facebook/react#3714 |
It seems there is not to much we can do without detecting the runtime environment.
I am not sure what do you mean. Can you share an example? |
Maybe we can make two subscriptions, one in componentWillMount() {
const subscription = this.vdom$.subscribe({
next: vdom => {
this.setState({ vdom }, subscription.unsubscribe)
}
})
this.propsEmitter.emit(this.props)
}
componentDidMount() {
this.subscription = this.vdom$.subscribe({
next: vdom => {
this.setState({ vdom })
}
})
} The one in |
Immediate unsubscription will cause cancellation of user created streams, in all cases its not an expected behavior. |
I guess |
Agree. I can't come up with other solutions. |
Seems like current
mapPropsStream
causes a memory leak at the server (server side rendering), and having that the idea to call subscribe atcomponentDidMount
is not the thing what I want in most cases,the workaround I see is to use at server side observable config like
As an example how take will help https://jsfiddle.net/2j2esxyL/7/
So having that there will be no call of
componentWillUnmount
at server side,take(1)
will close the stream so there will be no memory leaks and all event listeners will be removed.Even the solution above will not solve all the cases,
(the case at which mapPropsStream will wait something inside is not covered)
It seems like it will work for all cases I have internally.
I think if it's true (I haven't checked problem above) we need to add this into documentation.
@wuct ^
The text was updated successfully, but these errors were encountered: