-
Notifications
You must be signed in to change notification settings - Fork 120
Conversation
If someone is explicitly calling `Backbone.history.loadUrl` on the same route then the bindToRoute logic will leak as the event handler is never cleaned. Since this is something that presumably is relatively rare and backbone itself does some cleanup and routing events in response to this, restructuring the bindToRoute handle so that it will terminate the bound events in response to any route event.
I don't quite understand the problem here. Could you please elaborate on why calling |
So in situations like SSJS where we may commonly reuse routes, which leads to leaks/retention due to the route event bind. The memory will be released once a different route string comes in, but at least under the current distribution we have this is few and far between, leading to GC strain, etc. This is a breaking change but we are still in prerelease version on the 3.x line so we're fine from that aspect and it only impacts people who use I think the bigger question is if a route has changed when the route comes in but it is on the same path. I reasoned through this with @jhudson8 and came to the conclusion that it was since it's (1) a very explicit call by the client and (2) it means that the controller has executed and the objects that the bind to route was tied to are likely pertinent. |
So separate requests may hit the same route on the server side since we are reusing pages / VMs (or whatever you want to call them)? |
Yeah. We can run into MANY / requests in a row. |
They should not be affecting each other though, right? |
If this is merged then they will be isolated. If this is not merged then there is a chance (unlikely with the pending queue...) that /home request 1 could impact /home request 2. |
I'm almost certain that I figured out why this code was in here in the first place, if these are run in the handler directly then they will cancel as the route event occurs after the handler execs. I still stand by the conclusion that explicit |
Updated to support the prior to route event case. |
+1 from me |
This makes the logic even more complicated. I just spend 20 minutes trying to understand what problem it's solving, and I am sure if I come back to this code in a week I will have to spend another 20 minutes. I still don't understand why we are making breaking changes to make things work with separate requests on the server side when they are supposed to be completely isolated. Part of the problem I guess is that I am lacking understanding of how reuse works on the server side. If one request can trigger a route event in another request, is not it a problem? |
It's only a problem if you trigger a route that you are already on because the bindToRoute handler will not execute the callback which will stick around |
@candid I'll add docs to the code. It certainly is not obvious what this is We all agree that we don't want code to execute against a different route. On Friday, May 16, 2014, Joe Hudson [email protected] wrote:
Sent from my mobile device |
But it's not always different :) Regardless, it's not the actual change -Roman On Fri, May 16, 2014 at 10:01 AM, Kevin Decker [email protected]:
|
Blanket removing events is a very bad thing. This was the reason for one of the leaks we had in the hapi proxy. You should never remove events that you don't explicitly own, unless you KNOW that you explicitly own a particular object. Since we aren't making progress on this I'm going to make the call that a I've updated the patch to include further comments as to what the event handler is doing to make this clearer in the future as well as tests to improve coverage. |
For a variety of reasons getFragment can not be trusted prior to started, so for binds in these cases treat them as pending immediately. Fixes #311
Updated with changes that also help protect against issues with |
Tests failed, otherwise lgtm |
Released in 3.0.0-alpha.6 |
If someone is explicitly calling
Backbone.history.loadUrl
on the sameroute then the bindToRoute logic will leak as the event handler is never
cleaned.
Since this is something that presumably is relatively rare and backbone
itself does some cleanup and routing events in response to this,
restructuring the bindToRoute handle so that it will terminate the bound
events in response to any route event.
/cc @eastridge @ryan-roemer @candid