day8 / re-frame-10x

A debugging dashboard for re-frame. X-ray vision as tooling.
MIT License
634 stars 68 forks source link

Understand why zombie subscriptions are running #147

Open danielcompton opened 6 years ago

danielcompton commented 6 years ago

While developing re-frame-trace we've seen subscriptions that have been disposed are then re-run later. We need to work out whether this is due to:

c.f. https://github.com/reagent-project/reagent/pull/270.

mike-thompson-day8 commented 6 years ago

Didn't we establish that this is related to a figwheel reload?

Speculation: on a figwheel re-compile/reload, we dispose all existing subscriptions, and clear the subscription cache. We speculate that Zombies arise when one of these "gotten-rid-of' subscriptions comes back to life.

danielcompton commented 6 years ago

Figwheel reloading is the trigger, but it's still not clear what the mechanism is for resurrecting the disposed subscriptions. Your speculation seems correct to me, the question we need to answer is why do they come back, and how?

danielcompton commented 6 years ago

Looking more at this it seems like it is only triggered by Figwheel reloads of changes to re-frame-trace. This only happens when you are developing re-frame-trace alongside your main application. It doesn't appear to happen when your main application has a figwheel reload.

The cause of the zombie resurrection we've observed is an on-click handler dereferencing a subscription (and possibly not dereferencing the subscription within the view fn). What's not clear is how that on-click handler persists through the Figwheel reloads, as the on-jsload function is running which seems like it should trigger a re-render.

It would still be good to get to the bottom of this, but it's no longer a blocker for release.