# HG changeset patch # User Drew Perttula # Date 2017-06-10 09:14:01 # Node ID 9c5e62615a631af09fa0882ce29e69fece94bdb5 # Parent 9f7e31bf3f0c26ee11bdbbc6e51eb7794eeb27fe don't let handlers pile up (workaround) Ignore-this: c99eb0cce187fe7a49ba163431503680 diff --git a/light9/web/graph.coffee b/light9/web/graph.coffee --- a/light9/web/graph.coffee +++ b/light9/web/graph.coffee @@ -75,7 +75,11 @@ class AutoDependencies throw new Error("missing label") h = new Handler(func, label) - @handlerStack[@handlerStack.length - 1].innerHandlers.push(h) + tailChildren = @handlerStack[@handlerStack.length - 1].innerHandlers + matchingLabel = _.filter(tailChildren, ((c) -> c.label == label)).length + # ohno, something depends on some handlers getting run twice :( + if matchingLabel < 2 + tailChildren.push(h) console.time("handler #{label}") @_rerunHandler(h, null) console.timeEnd("handler #{label}") @@ -93,10 +97,20 @@ class AutoDependencies #log('done. got: ', handler.patterns) @handlerStack.pop() # handler might have no watches, in which case we could forget about it + + _logHandlerTree: -> + log('handler tree:') + prn = (h, depth) -> + indent = '' + for i in [0...depth] + indent += ' ' + log(indent + h.label) + for c in h.innerHandlers + prn(c, depth + 1) + prn(@handlers, 0) graphChanged: (patch) -> # SyncedGraph is telling us this patch just got applied to the graph. - rerunInners = (cur) => toRun = cur.innerHandlers.slice() for child in toRun @@ -188,7 +202,6 @@ class window.SyncedGraph if not q.graph? throw new Error("corrupt patch: #{q}") - log('graph: patch', patch) @_applyPatch(patch) @_client.sendPatch(patch) if @_client