_listeners is empty in eventProxy
See original GitHub issueThis may well be an issue in our application code, and not preact, but I’m wondering of you can shed some light on why it might happen.
I’m wrapping all event handlers so that we can trap errors and report them correctly (otherwise window.onerror receives no data from async events in cdn hosted bundles).
We’re getting a significant number of this._listeners[t.type] is not a function errors in preact’s eventProxy
handler (which we wrap).
The value of this
is typically
context: {
_component: None,
_componentConstructor: None,
_listeners: {},
normalizedNodeName: div
},
and the event logs as simply {isTrusted: true}
I’m guessing that this is because handler function is not resolved until the event is triggered, and the registering component has already unmounted by then.
(Most of these errors seem to originate from various windows OSes btw.)
Is it worth you putting a guard into eventProxy, or is this something we should be preventing on our end.
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Yep, I think you nailed it. I was recursively wrapping functions. Occurrences dropped dramatically. Thanks!
I’m experiencing something similar on 8. Every so often after refreshing a bunch (Chrome mac),
this._listeners
is undefined ineventProxy
.Not doing anything fancy, just an
<img onLoad={ ... }>
and get