php system_error ai_generated true

Symfony\Component\Process\Exception\ProcessTimedOutException:进程 "'php' 'artisan' 'queue:work' '--queue=high,default' '--timeout=60'" 超过了 60 秒的超时时间。

Symfony\Component\Process\Exception\ProcessTimedOutException: The process "'php' 'artisan' 'queue:work' '--queue=high,default' '--timeout=60'" exceeded the timeout of 60 seconds.

ID: php/laravel-queue-worker-timeout-exceeded

其他格式: JSON · Markdown 中文 · English
85%修复率
85%置信度
1证据数
2024-02-18首次发现

版本兼容性

版本状态引入弃用备注
Laravel 9 active
Laravel 10 active
Laravel 11 active

根因分析

Laravel 队列工作进程因超时设置而被杀死,因为某个作业的执行时间超过了配置的超时时间,通常是由于外部 API 调用缓慢、数据库查询慢或无限循环。

English

The Laravel queue worker process is being killed by the timeout setting because a job is taking longer than the configured timeout to execute, often due to slow external API calls, database queries, or infinite loops.

generic

官方文档

https://laravel.com/docs/10.x/queues#timeout

解决方案

  1. Increase the timeout for the specific queue worker: `php artisan queue:work --timeout=120` (set to 120 seconds). Also update the `--timeout` option in your supervisor configuration if using it.
  2. Identify and optimize the slow job. Add logging to track execution time: `$start = microtime(true); // ... job logic ... \Log::info('Job took: ' . (microtime(true) - $start) . ' seconds');` Then refactor the job to use chunked processing, caching, or queueable API calls.

无效尝试

常见但无效的做法:

  1. Setting the timeout to a very high value like 3600 seconds without investigating the root cause 80% 失败

    This only masks the problem; if a job hangs indefinitely, it will still eventually timeout or consume excessive resources, and the queue will stall.

  2. Restarting the queue worker with `php artisan queue:restart` 95% 失败

    Restarting does not fix the underlying slow job; the job will be retried and fail again with the same timeout.