Use of uninitialized value $cb in method lookup at Mojo/Reactor/Poll.pm
e477 opened this issue · comments
- Mojolicious version: 9.34
- Perl version: 5.38.0
- Operating system: Debian Linux 12
We use the Mojo::UserAgent for our data scraper and we get lots of errors like this:
Use of uninitialized value $cb in method lookup at /usr/local/lib/perl5/Mojo/Reactor/Poll.pm line 141.
eval {...} called at /usr/local/lib/perl5/Mojo/Reactor/Poll.pm line 141
Mojo::Reactor::Poll::_try(Mojo::Reactor::EV=HASH(0x564e73e33fd8), "I/O watcher", undef, 0)
called at /usr/local/lib/perl5/Mojo/Reactor/EV.pm line 54
Looking at the code, the docs and similar bug reports this seems to be the result of EV::io emitting two or more events in succession with the earlier event removing the handler while the callback for a later event is still pending.
Mojo/Reactor/EV.pm will catch this situation, but only for write events (line 55). For read events the check for existance of the handler is missing (line 54).
Steps to reproduce the behavior
I've yet been unable to reproduce this error in a test case.
Expected behavior
No errors.
Actual behavior
See above.
Suppose a shared check for the data structure would make sense. This has to be incredibly rare though.