Skip to content

Not whole file is read if use the eio adapter #73

@Logioniz

Description

@Logioniz

Steps to reproduce behavior

1. create file

php -r 'foreach(range(0, 1000000) as $i) { print $i . PHP_EOL; }' > static/test.txt

2. create script

<?php

use \React\Promise\Deferred;

$loader = require __DIR__ . '/vendor/autoload.php';

#$loop = React\EventLoop\Factory::create();
$loop = new React\EventLoop\ExtEvLoop();

$filesystem = \React\Filesystem\Filesystem::create($loop);
    $file = $filesystem->file('static/test.txt');
    $file->exists()
        ->then(function () use ($file) {
            return $file->open('r');
        })
        ->then(function ($stream) use ($loop) {
            $d = new Deferred();
            $stream->on('data', function ($data) {
                print $data;
            });
            $stream->on('end', function ($data) use ($stream, $d) {
                $stream->close();
                $d->resolve('finish');
            });

            return $d->promise();
        })
        ->then(function () use ($loop) {
            $loop->stop();
        })
        ->otherwise(function ($e) {
            var_dump($e);
        });
$loop->run();

3. run

php7.3 3.php
0
1
2
3
...
375148
375149
3751root@7cf1e7fada2c:/app/adv# 

if you change the adapter to child process then everything works well

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions