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

Silent error? The output returned by this child process is too large #234

Open
programarivm opened this issue Oct 4, 2024 · 0 comments
Open

Comments

@programarivm
Copy link

👋 Hello there,

We're parallelizing long-running tasks with the help of spatie/async and everything is going smoothly.

However, src/Command/Data/AnnotationsGameAsyncTask.php seems to be failing silently when the output sent to the browser is a few kilobytes (KB) in size.

<?php

// src/Command/Data/AnnotationsGameAsyncTask.php

namespace ChessServer\Command\Data;

use ChessServer\Socket\AbstractSocket;
use Spatie\Async\Task;

class AnnotationsGameAsyncTask extends Task
{
    const ANNOTATIONS_GAMES_FILE = 'annotations_games.json';

    public function configure()
    {
    }

    public function run()
    {
        $contents = file_get_contents(AbstractSocket::DATA_FOLDER.'/'.self::ANNOTATIONS_GAMES_FILE);

        return json_decode($contents);
    }
}

The annotations_games.json file was recently resized for the command to work properly. See chesslablab/chess-server@4e66dd9

<?php

// src/Command/Data/AnnotationsGameCommand.php

namespace ChessServer\Command\Data;

use ChessServer\Command\AbstractCommand;
use ChessServer\Socket\AbstractSocket;

class AnnotationsGameCommand extends AbstractCommand
{
    public function __construct()
    {
        $this->name = '/annotations_game';
        $this->description = 'Annotated chess games.';
    }

    public function validate(array $argv)
    {
        return count($argv) - 1 === 0;
    }

    public function run(AbstractSocket $socket, array $argv, int $id)
    {
        $this->pool->add(new AnnotationsGameAsyncTask(), 128000)
            ->then(function ($result) use ($socket, $id) {
                return $socket->getClientStorage()->send([$id], [
                    $this->name => $result,
                ]);
            });
    }
}

Now I'm wondering if the pool could be set up for this command to download files of several dozen kilobytes, let's say 64 KB.

🙏 Thanks for the help, and keep up the great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant