horizon: ERROR: A non-numeric value encountered
- Horizon Version: 3.2.1
- Laravel Version: 5.7.28
- PHP Version: 7.1.26
- Redis Driver & Version: predis 1.1.1
- Database Driver & Version: mysql 5.7
Description:
When launching php artisan horizon, after the installation steps listed in the documentation, the system works but keeps throwing this Exception every second or so:
{
"class": "ErrorException",
"message": "A non-numeric value encountered",
"code": 0,
"file": "\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1682",
"trace": [
"\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1682",
"{\"function\":\"Illuminate\\\\Support\\\\{closure}\",\"class\":\"Illuminate\\\\Support\\\\Collection\",\"type\":\"->\",\"args\":[0,{\"cpu\":0.47,\"mem\":\"www\"}]}",
"\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1415",
"\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1683",
"\/var\/www\/vendor\/laravel\/horizon\/src\/Repositories\/RedisSupervisorRepository.php:129",
"{\"function\":\"Laravel\\\\Horizon\\\\Repositories\\\\{closure}\",\"class\":\"Laravel\\\\Horizon\\\\Repositories\\\\RedisSupervisorRepository\",\"type\":\"->\",\"args\":[\"[object] (Predis\\\\Pipeline\\\\Pipeline)\"]}",
"\/var\/www\/vendor\/predis\/predis\/src\/Pipeline\/Pipeline.php:211",
"\/var\/www\/vendor\/predis\/predis\/src\/Client.php:445",
"\/var\/www\/vendor\/predis\/predis\/src\/Client.php:396",
"\/var\/www\/vendor\/predis\/predis\/src\/Client.php:418",
"\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Redis\/Connections\/Connection.php:114",
"\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Redis\/Connections\/Connection.php:214",
"\/var\/www\/vendor\/laravel\/horizon\/src\/Repositories\/RedisSupervisorRepository.php:138",
"\/var\/www\/vendor\/laravel\/horizon\/src\/Supervisor.php:354",
"\/var\/www\/vendor\/laravel\/horizon\/src\/Supervisor.php:308",
"\/var\/www\/vendor\/laravel\/horizon\/src\/Supervisor.php:267",
"\/var\/www\/vendor\/laravel\/horizon\/src\/Console\/SupervisorCommand.php:92",
"\/var\/www\/vendor\/laravel\/horizon\/src\/Console\/SupervisorComman…
I was able to fix it temporarily by updating
vendor/laravel/horizon/src/SystemProcessCounter.php at line 33:
return ['cpu' => $row->first() / 100, 'mem' => $row->last()];
to
return ['cpu' => $row->first() / 100, 'mem' => (float)$row->last()];
It probably can be fixed in a better way, but that’s the spot where it was breaking, by sending 0.00 instead of “0.00”. Looking forward to an update to avoid having to manually change my vendor files. O_o 😄
Steps To Reproduce:
- Install Redis
- Install Horizon
- Launch php artisan horizon
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 16 (10 by maintainers)
A little more digging here shows that https://github.com/gliderlabs/docker-alpine/issues/173#issuecomment-218620191 contains the answer for alpine linux users. Why this has worked for me up until this point I don’t know.
Here is what I have in mind:
In light of the bugs in the last couple of weeks and the performance hit we’ve decided to revert the original PR. Please see my answer here: https://github.com/laravel/horizon/pull/589#issuecomment-502085735
The two dashes is fine. Feel free to send in a PR.