mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.66k stars 577 forks source link

Fix Promise->map hang on false values after concurrency limit #2084

Closed ilmari closed 1 year ago

ilmari commented 1 year ago

The check for whether to call the callback returned early if the item was falsy. Instead, it needs to only return early if there are no items left.

jberger commented 1 year ago

In theory this can be done without adding another line by making the later line https://github.com/mojolicious/mojo/pull/2084/files#diff-d48a9dbb018a19b463cfae82ffb2a5fd0cfe0cf4a553c09f8aba1048aaaaba0aR78 instead say for shift @$items but I don't know if that makes the line too long or too inscrutable. @kraih?

jberger commented 1 year ago

Either way, I approve

ilmari commented 1 year ago

for shift @$items

Another option would be return () unless my ($item) = splice(@items, 0, 1);, since splice returns an empty list if the input is empty, and list assignment returns the number of items assigned, regardless of their truthiness.