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

Error of activate the readable watcher for event extension #276

Closed
deadbeat88 opened this issue Jun 11, 2019 · 7 comments
Closed

Error of activate the readable watcher for event extension #276

deadbeat88 opened this issue Jun 11, 2019 · 7 comments
Labels

Comments

@deadbeat88
Copy link

At application where there are a lot of async filesytem operations, also uses rabbitmq and postgres. Sometimes I get the following error: Warning: Event::__construct(): 2 bytes of buffered data lost during stream conversion!' at /var/www/vendor/amphp/amp/lib/Loop/EventDriver.php:245 and then application is crushed. Any idea with this error? Use v2.1.2.

@kelunik kelunik added the bug label Jun 11, 2019
@kelunik
Copy link
Member

kelunik commented Jun 11, 2019

I have no idea why that might happen. Could you report that as a bug to the event extension at https://bitbucket.org/osmanov/pecl-event?

@rosmanov
Copy link

rosmanov commented Jun 14, 2019

@deadbeat88 created an issue here: https://bitbucket.org/osmanov/pecl-event/issues/56/bug-of-stream-conversion.

The warning occurs when Event::__construct tries to obtain numeric file descriptor from a PHP stream resource. I don't know how to handle this warning except using the PHP_STREAM_CAST_INTERNAL flag ("stream cast for internal use"). The flag even seems to be appropriate in our case 🤔

It should be noted that the warning wouldn't appear in case of using numeric file descriptor, or a socket resource instead of a PHP stream.

@kelunik
Copy link
Member

kelunik commented Jun 14, 2019

@rosmanov I guess it might be a TLS socket?

@deadbeat88 Could you check with stream_get_meta_data which kind of steam is responsible for that warning?

@rosmanov
Copy link

@kelunik could be just any stream resource (resource created with the sockets extension is a different thing)

@kelunik @deadbeat88 I've now added PHP_STREAM_CAST_INTERNAL flag in the master branch. Let's check if everything is okay. If it is, I'll publish a new PECL release.

@deadbeat88
Copy link
Author

deadbeat88 commented Jun 14, 2019

Today after your comment about stream resource I narrowed down the search and found that the error occurs when using Amp\Process\Proccess:

$process = new Process($cmd);
yield $process->start();
/** @var string $content */
$content = yield buffer($process->getStdout());
/** @var int $code */
$code = yield $process->join();

for example for $cmd='cd "/tmp/i_48daffb4fba88a87d24d95adb2c583cd934dc775" && zip 48daffb4fba88a87d24d95adb2c583cd934dc775 receipts.xml'

Approximately 1 time out of 10-15 when executing the code

/** \Amp\ByteStream\buffer */
while (($chunk = yield $source->read()) !== null) {
    $buffer .= $chunk;
    $chunk = null; // free memory
}

ends with an error.

Later, I will check with an update of event extension)

@deadbeat88
Copy link
Author

deadbeat88 commented Jun 17, 2019

@rosmanov released new version 2.5.3, bug fixed and issue can be closed.

@kelunik
Copy link
Member

kelunik commented Jun 17, 2019

Cool!

@kelunik kelunik closed this as completed Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants