Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event::set(): supplied resource is not a valid #136

Closed
DangerLifter opened this issue Dec 12, 2017 · 4 comments · Fixed by reactphp/socket#141 or #139
Closed

Event::set(): supplied resource is not a valid #136

DangerLifter opened this issue Dec 12, 2017 · 4 comments · Fixed by reactphp/socket#141 or #139
Assignees
Milestone

Comments

@DangerLifter
Copy link

DangerLifter commented Dec 12, 2017

There is a heavy script which is running 24x7. Before it worked on php5.6 + libevent + php libevent + react. After update to php 7.1 + libevent + php event (React\EventLoop\ExtEventLoop) + react I got periodical crashes with stack below. I am trying to debug issue, but it is difficult cause issue happens relatively rarely. Any help or ideas would be great.

> [2017-12-11 13:45:47] prod.ALERT: ErrorException: Event::set(): supplied resource is not a valid Socket resource in /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php:264
> Stack trace:
> #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Event::set(): s...', '/home/projects/...', 264, Array)
> #1 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(264): Event->set(Object(EventBase), Resource id #118542, 20, Object(Closure))
> #2 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(96): React\EventLoop\ExtEventLoop->unsubscribeStreamEvent(Resource id #118542, 2)
> #3 /home/projects/application/vendor/react/stream/src/DuplexResourceStream.php(105): React\EventLoop\ExtEventLoop->removeReadStream(Resource id #118542)
> #4 /home/projects/application/vendor/react/stream/src/DuplexResourceStream.php(139): React\Stream\DuplexResourceStream->pause()
> #5 /home/projects/application/vendor/react/socket/src/Connection.php(116): React\Stream\DuplexResourceStream->close()
> #6 /home/projects/application/vendor/react/http-client/src/Request.php(218): React\Socket\Connection->close()
> #7 /home/projects/application/vendor/react/http-client/src/Request.php(205): React\HttpClient\Request->close()
> #8 /home/projects/application/vendor/react/http-client/src/Request.php(178): React\HttpClient\Request->closeError(Object(RuntimeException))
> #9 /home/projects/application/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): React\HttpClient\Request->handleEnd()
> #10 /home/projects/application/vendor/react/stream/src/Util.php(71): Evenement\EventEmitter->emit('end', Array)
> #11 /home/projects/application/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): React\Stream\Util::React\Stream\{closure}()
> #12 /home/projects/application/vendor/react/stream/src/DuplexResourceStream.php(196): Evenement\EventEmitter->emit('end')
> #13 [internal function]: React\Stream\DuplexResourceStream->handleData(Resource id #118542)
> #14 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(299): call_user_func(Array, Resource id #118542)
> #15 [internal function]: React\EventLoop\ExtEventLoop->React\EventLoop\{closure}(Resource id #118542, 6, NULL)
> #16 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(182): EventBase->loop(3)
> #17 /home/projects/application/library/Main.php(163): React\EventLoop\ExtEventLoop->run()
> 
> Next Exception: Expected either valid PHP stream or valid PHP socket resource in /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php:264
> Stack trace:
> #0 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(264): Event->set(Object(EventBase), Resource id #118542, 20, Object(Closure))
> #1 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(96): React\EventLoop\ExtEventLoop->unsubscribeStreamEvent(Resource id #118542, 2)
> #2 /home/projects/application/vendor/react/stream/src/DuplexResourceStream.php(105): React\EventLoop\ExtEventLoop->removeReadStream(Resource id #118542)
> #3 /home/projects/application/vendor/react/stream/src/DuplexResourceStream.php(139): React\Stream\DuplexResourceStream->pause()
> #4 /home/projects/application/vendor/react/socket/src/Connection.php(116): React\Stream\DuplexResourceStream->close()
> #5 /home/projects/application/vendor/react/http-client/src/Request.php(218): React\Socket\Connection->close()
> #6 /home/projects/application/vendor/react/http-client/src/Request.php(205): React\HttpClient\Request->close()
> #7 /home/projects/application/vendor/react/http-client/src/Request.php(178): React\HttpClient\Request->closeError(Object(RuntimeException))
> #8 /home/projects/application/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): React\HttpClient\Request->handleEnd()
> #9 /home/projects/application/vendor/react/stream/src/Util.php(71): Evenement\EventEmitter->emit('end', Array)
> #10 /home/projects/application/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(123): React\Stream\Util::React\Stream\{closure}()
> #11 /home/projects/application/vendor/react/stream/src/DuplexResourceStream.php(196): Evenement\EventEmitter->emit('end')
> #12 [internal function]: React\Stream\DuplexResourceStream->handleData(Resource id #118542)
> #13 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(299): call_user_func(Array, Resource id #118542)
> #14 [internal function]: React\EventLoop\ExtEventLoop->React\EventLoop\{closure}(Resource id #118542, 6, NULL)
> #15 /home/projects/application/vendor/react/event-loop/src/ExtEventLoop.php(182): EventBase->loop(3)
> #16 /home/projects/application/library/Main.php(163): React\EventLoop\ExtEventLoop->run()
> 
@WyriHaximus
Copy link
Member

@DangerLifter We're looking into this issue, can you show the output of composer show | grep react?

@clue
Copy link
Member

clue commented Dec 19, 2017

Thank you! We have debugged this problem and have a fairly good understanding of what is going on now. I will try to file a test case and fix for this later today. As a temporary workaround, can you try pinning react/stream to v0.7.4 to see if the problem goes away?

@DangerLifter
Copy link
Author

In case if usage react/event-loop dev-master:

Symfony\Component\Debug\Exception\FatalThrowableError: Call to private method React\EventLoop\ExtEventLoop::removeStream() from context 'React\Stream\DuplexResourceStream' in /var/www/projects/DomainScrapperUpd/vendor/react/stream/src/DuplexResourceStream.php:134
Stack trace:
#0 /var/www/projects/DomainScrapperUpd/vendor/react/stream/src/DuplexResourceStream.php(190): React\Stream\DuplexResourceStream->close()

@clue
Copy link
Member

clue commented Dec 24, 2017

Thank you for your patience! We've just fixed the root cause with reactphp/socket#141, so updating to react/socket v0.8.7 should fix this issue :shipit:

Please let us know if this problem persists and we're happy to look into this again 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment