Skip Menu |

This queue is for tickets about the IO-Async CPAN distribution.

Report information
The Basics
Id: 104128
Status: resolved
Priority: 0/
Queue: IO-Async

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.66
Fixed in: 0.68



Subject: Nonobvious error message to Stream->write when not in a Loop
$ perl -MIO::Async::Stream -E 'IO::Async::Stream->new_for_stdout->write("Hello, world")->get' Can't call method "new_future" on an undefined value at /home/leo/lib/perl5/IO/Async/Stream.pm line 838. -- Paul Evans
On Thu Apr 30 11:36:52 2015, PEVANS wrote: Show quoted text
> $ perl -MIO::Async::Stream -E 'IO::Async::Stream->new_for_stdout-
> >write("Hello, world")->get'
> Can't call method "new_future" on an undefined value at > /home/leo/lib/perl5/IO/Async/Stream.pm line 838.
Something of an improvement. Perhaps. $ perl -Mblib -MIO::Async::Stream -E 'IO::Async::Stream->new_for_stdout->write("Hello, world")->get' Cannot ->write data returning a Future to a Stream not in a Loop at -e line 1. -- Paul Evans
Subject: rt104128.patch
=== modified file 'lib/IO/Async/Stream.pm' --- lib/IO/Async/Stream.pm 2015-04-17 19:43:46 +0000 +++ lib/IO/Async/Stream.pm 2015-06-01 13:32:34 +0000 @@ -835,7 +835,10 @@ if( defined wantarray ) { my $orig_on_flush = $on_flush; my $orig_on_error = $on_error; - $f = $self->loop->new_future; + + my $loop = $self->loop or + croak "Cannot ->write data returning a Future to a Stream not in a Loop"; + $f = $loop->new_future; $on_flush = sub { $f->done; $orig_on_flush->( @_ ) if $orig_on_flush;
Released -- Paul Evans