Closed cometta closed 7 years ago
@cometta Is there a stack trace that comes along with that error? It looks like it is only pointing to Rx code.
@cometta I'm able to replicate the error. Let me look into a fix
This one was a hard one to track down.
Looks like the behavior of Subject.prototype.complete was changed between Rx beta used in 0.2.0 and Rx v5 used in 0.3.0 so that it no longer creates a local var of the observers before eventually calling unsubscribe.
This causes a serious of events within renderToString which causes the error above:
wrappedRootEpic.complete
is called in initialRender
. actionsProxy.complete
which intern causes the actions
obs' passed into the user epic to complete, which itself triggers the lifecycle.complete
. This all happens synchronously.lifecycle
is a subject so it's complete will cycle through all the observers synchronously one by one and call their complete method here.last
and map
operators in renderToString
.map
operator will call wrappedRootEpic.unsubscribe
.wrappedRootEpic
will then call lifecycle.unsubscribe
which will null the observers property. Keep in mind that this is all happening synchronously which means that somewhere in the call stack the lifecycle.complete
function has yet to resolve and is waiting for all of it's observers to complete. This is the last function on the call stack to finish. Once it resolves we start working our way back down the stack.lifecycle
observers have completed it will then set the length of the observers array to zero (this effectively blanks our the array). But since the lifecycle.unsubscribe
function was called before this function could complete it will attempt to set the length property of a null object causing the error.tl:dr; We need to make sure the wrappedRootEpic.unsubscribe
happens after the wrappedRootEpic.complete
function has resolved.
I've got a fix for this but I want to get a failing test before I submit it.
@BerkeleyTrue ,if you create a branch of the changes, i can help you to test it.
@cometta I've got a PR going through travis if you want to check it out
Fix released as 0.3.1
yup, it's working in 0.3.1, thank you @BerkeleyTrue
👍
I get below error, any example for using renderToString().subscribe(..) for 0.3.0? It was working on 0.1.0