Binding error when removing form element

I’m seeing the following error in the console, seemingly when I navigate in my app and remove form elements from the dom:

tasks.js:210 Uncaught TypeError: Cannot read property 'Symbol(zone-eventhandler)' of undefined
    at HTMLInputElement.eval (tasks.js:210)
    at HTMLInputElement.wrappedFn [as removeEventListener] (register.js:104)
    at HTMLInputElement.removeEventListener (events.js:32)
    at HTMLInputElement.events.removeEventListener (make-mutation-event.js:91)
    at HTMLInputElement.events.removeEventListener (attributes.js:81)
    at HTMLInputElement.events.removeEventListener (make-mutation-event.js:91)
    at HTMLInputElement.domEvents.removeEventListener (attr.js:658)
    at HTMLInputElement.removeEventListener (add-event-compat.js:79)
    at HTMLInputElement.removeEventListener (add-event-compat.js:79)
    at HTMLInputElement.off (can-event.js:232)

(anonymous) @ tasks.js:210
wrappedFn @ register.js:104
removeEventListener @ events.js:32
events.removeEventListener @ make-mutation-event.js:91
events.removeEventListener @ attributes.js:81
events.removeEventListener @ make-mutation-event.js:91
domEvents.removeEventListener @ attr.js:658
removeEventListener @ add-event-compat.js:79
removeEventListener @ add-event-compat.js:79
off @ can-event.js:232
observation.(anonymous function) @ can-stache-bindings.js:876
(anonymous) @ observe.js:23
unbindUpdate @ can-stache-bindings.js:1428
onTeardown @ can-stache-bindings.js:1308
(anonymous) @ can-stache-bindings.js:340
one @ can-event.js:271
dispatch @ events.js:71
module.exports @ dispatch.js:21
handler @ make-mutation-event.js:50
(anonymous) @ document.js:28
dispatchIfListening @ document.js:27
(anonymous) @ document.js:110
each @ each.js:22
(anonymous) @ document.js:103
mutationData.handler @ document.js:102
(anonymous) @ document.js:44
(anonymous) @ document.js:43
Task.run @ zone.js:41
Zone.runTask @ zone.js:183
(anonymous) @ zone.js:260
childList (async)
insertBefore @ mutate.js:144
after @ can-view-nodelist.js:428
replace @ can-view-nodelist.js:458
makeAndPut @ html.js:82
(anonymous) @ html.js:55
(anonymous) @ can-observation.js:698
callHandlers @ can-observation.js:697
update @ can-observation.js:234
Observation.updateAndNotify @ can-observation.js:409
dispatchSync @ can-event.js:184
flush @ batch.js:331
stop @ batch.js:284
canRoute.setState @ can-route.js:342

Has anyone come across this? Am I not properly cleaning something up?

Hey @Jared_Stehler, sorry for not responding sooner.

I haven’t seen this before; any chance you could show some of the code/template that makes this happen? Also, is this with the latest can-zone?

This is with can-zone 0.6.16. I’ll post some code snippets when I get a chance.

Have there been any updates on this? We’re having the same issue. We also have a very large (~15-20 megs per interaction) memory leak that I suspect may be connected.

@RyanMilligan we can fix it right away if we can get some example code. Anyway you can get us something showing the error?

I would love to, but we have a fairly large shared library of components and utilities, and I honestly have no idea what part of it would be necessary to create a minimal repro. I will say that we updated to the latest version of can-zone and still had both the error and the memory leak.

My theory is that something is trying to unsubscribe event handlers that have been “lost” somehow (hence the undefined callback), but that are actually still subscribed, which is what causes the memory leak.

I’ll see what I can do in terms of a minimal repro, but it may be a little while. I was hoping maybe @Jared_Stehler had started to put something together and just got distracted.

Alternatively, we could pair with you to find and resolve the issue. Would a screen share work?

I’m available for a screen share. @RyanMilligan “distracted” doesn’t even begin to describe… lol :wink:

I don’t think I’m doing anything too special; I’ve got a switch on my index.stache for the router page, and I seem to get this error whenever I switch to a page after having been on one where I’ve got form elements with bindings (i.e. value:bind).

@matthewp who knows this best is on vacation today and Monday. I just had baby #2 so my schedule is hectic. Is there a time on Tuesday that works for you where Matthew can pair?

I would be up for a screen share to resolve this as well, if Jared has difficulty scheduling it. So far everything he’s said seems to apply to me as well.

@RyanMilligan and I are going to screenshare about this on Monday. Will let everyone know if we get to the bottom of it.

Good news, we figured out the problem and a fix has been released! Update to can-zone@0.6.18 get it. @Jared_Stehler

Nice! Glad to year this was resolved.

This release fixed the issue for me as well! Thanks all.