async
async copied to clipboard
Silent error? The output returned by this child process is too large
👋 Hello there,
We're parallelizing long-running tasks with the help of spatie/async and everything is going smoothly.
- https://github.com/chesslablab/chess-server/issues/382
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 https://github.com/chesslablab/chess-server/commit/4e66dd999c0d2380de4adaa62bb79097c60da072
<?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!