question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

_listeners is empty in eventProxy

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
angus-ccommented, Mar 31, 2017

Yep, I think you nailed it. I was recursively wrapping functions. Occurrences dropped dramatically. Thanks!

0reactions
gpoitchcommented, Apr 13, 2017

I’m experiencing something similar on 8. Every so often after refreshing a bunch (Chrome mac), this._listeners is undefined in eventProxy.

Not doing anything fancy, just an <img onLoad={ ... }> and get

Uncaught TypeError: Cannot read property 'load' of undefined
    at HTMLImageElement.eventProxy (preact.js:96)
Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Does jQuery empty detach listeners attached via ...
empty() removes the child elements from the parent(s). Any event listeners attached to the elements will no longer exist, as the children ...
Read more >
Add a click event listener on the button. Pass an empty ...
Add a click event listener on the button. Pass an empty function in as the second parameter. Need a little help. No clue...
Read more >
Events | Node.js v19.3.0 Documentation
Any values returned by the called listeners are ignored and discarded. The following example shows a simple EventEmitter instance with a single listener....
Read more >
Homework: Event Handling with Event Listeners
In this lesson, we'll learn a new method of event handling: we'll create event listeners in our code to listen for and react...
Read more >
EventTarget.removeEventListener() - Web APIs | MDN
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found