Skip to content

feat: make Task execute timeout configurable via connection "task_timeout" (default 10s)#2

Merged
Chance-fyi merged 1 commit into
Chance-fyi:masterfrom
nirolee:feat/configurable-task-timeout
Jun 8, 2026
Merged

feat: make Task execute timeout configurable via connection "task_timeout" (default 10s)#2
Chance-fyi merged 1 commit into
Chance-fyi:masterfrom
nirolee:feat/configurable-task-timeout

Conversation

@nirolee

@nirolee nirolee commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Problem

All SQL Server queries are executed inside a Hyperf Task (to simulate coroutines over the blocking PDO/ODBC driver). SqlServerTask's methods use a bare #[Task], so the task execute timeout is the Hyperf default of 10 seconds, hardcoded with no way to change it.

A query that legitimately runs longer than 10s fails with:

[ERROR] Task [N] execute timeout.

and its result is lost. We hit this in production on a heavy multi-table report query that intermittently crosses 10s.

Change

Make the task execute timeout configurable per connection via a task_timeout option (in seconds), defaulting to 10 to keep current behaviour.

  • SqlServerConnection now dispatches the task through TaskExecutor with the configured timeout instead of relying on the static #[Task] annotation.
  • The #[Task] attribute on SqlServerTask is removed accordingly — dispatch is now explicit; execution inside the task worker is unchanged.
  • Fully backward compatible: without task_timeout the timeout stays 10s, so existing users need no change.

Usage

// config/autoload/databases.php
'sqlsrv' => [
    'driver'       => 'sqlsrv',
    // host / database / username / password / ...
    'task_timeout' => 60, // optional, seconds, default 10
],

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

Successfully merging this pull request may close these issues.

2 participants