Skip to content

fix(data-transfer): clear the worker timeout alarm when the queue drains - #722

Merged
navneetkumar-pim-webkul merged 2 commits into
3.xfrom
fix/queue-worker-timeout-alarm
Sep 23, 2026
Merged

navneetkumar-pim-webkul merged 2 commits into
3.xfrom
fix/queue-worker-timeout-alarm

Conversation

@navneetkumar-pim-webkul

Copy link
Copy Markdown
Collaborator

Issue Reference

N/A — found while investigating the failing TIA Baseline run: https://github.com/unopim/unopim/actions/runs/35849737689/job/107144309998

Description

Webkul\DataTransfer\Queue\Worker::singleJobDaemon() arms pcntl_alarm() (the job timeout) before fetching a job, then breaks out of the loop on an empty queue before resetTimeoutHandler() runs. The alarm outlives the unopim:queue:work command and, --timeout seconds later (default 60), the framework's timeout handler calls Worker::kill() → posix_kill(getmypid(), SIGKILL) on whatever process invoked it.

The TIA Baseline workflow runs JobLauncherTest in-process, so the whole Pest run was SIGKILLed (exit 137) exactly 60.0s after that test finished — no memory pressure, no OOM entry in dmesg. It has failed this way on every run since at least 2026-08-21.

Fix: reset the timeout handler in a finally block so every exit path (empty queue break, or an exception from runJob()) disarms the alarm. Behaviour while a job is running is unchanged — a hung job is still killed at --timeout.

Also applies Rector's PHP 8.4 new without parentheses on one untouched line in the same file.

Impact: running unopim:queue:work as its own CLI process behaves the same (the process exited anyway). Callers that invoke it in-process (Artisan::call(), tests) are no longer killed 60s later. Laravel's standard queue:work is not affected.

How To Test This?

  1. vendor/bin/pest packages/Webkul/Admin/tests/Feature/DataTransfer/Command/JobLauncherTest.php
  2. New test clears the worker timeout alarm once the queue is drained asserts pcntl_alarm(0) === 0 after the command.
  3. Without the fix it fails with Failed asserting that 60 is identical to 0.; with the fix all 4 tests pass.
  4. After merge, the TIA Baseline workflow on 3.x should no longer be killed with exit 137.

Screenshots

N/A — no UI change.

Checklist

  • vendor/bin/pest passes locally (JobLauncherTest + WorkerTest, 5 passed)
  • vendor/bin/pint --test reports no style issues
  • Tailwind classes are reordered — N/A, no frontend change
  • New user-facing strings use translation keys — N/A, no new strings
  • Target branch is 3.x (patch branch, merged up to master)

Documentation

  • My pull request requires an update on the documentation repository.

singleJobDaemon() armed pcntl_alarm() before fetching a job, then broke
out of the loop on an empty queue before resetTimeoutHandler() ran. The
alarm outlived the command and, --timeout seconds later, the framework's
timeout handler SIGKILLed whatever process had invoked it. The TIA
baseline recording runs JobLauncherTest in-process and was killed with
exit 137 exactly 60s after that test finished.

Reset the handler in a finally block so every exit path disarms it.
Copilot AI lite review requested due to automatic review settings September 23, 2026 11:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The critical and moderate test issues remain unresolved, and exception-path cleanup coverage is still missing.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes stale DataTransfer worker timeout alarms that can terminate in-process callers after the queue drains.

Changes:

  • Resets timeout handlers in a finally block.
  • Updates ReflectionMethod syntax.
  • Adds a queue-drain alarm regression test.
File Summary and review findings
packages/​Webkul/​DataTransfer/​src/​Queue/​Worker.php Clears alarms on loop exit and updates PHP 8.4 syntax. Nit (1 vote): Add coverage for alarm cleanup when runJob() throws.
packages/​Webkul/​Admin/​tests/​Feature/​DataTransfer/​Command/​JobLauncherTest.php Adds alarm-cleanup coverage. Critical (1 vote): Guard or skip the assertion when ext-pcntl is unavailable. Moderate (1 vote): Remove the extra run() call after assertSuccessful().

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@navneetkumar-pim-webkul
navneetkumar-pim-webkul merged commit 53aba9e into 3.x Sep 23, 2026
23 checks passed
@navneetkumar-pim-webkul
navneetkumar-pim-webkul deleted the fix/queue-worker-timeout-alarm branch September 23, 2026 12:22
@navneetkumar-pim-webkul navneetkumar-pim-webkul mentioned this pull request Sep 24, 2026
2 of 6 tasks
navneetkumar-pim-webkul added a commit that referenced this pull request Sep 24, 2026
Six merged pull requests since v3.1.1 carried no changelog entry: the
gallery unsaved badge and worker timeout handler (#713), the import filter
re-render (#720), the worker timeout alarm (#722), the channel name on
PostgreSQL (#725), the price input height (#726), and the export view
events (#717, #718). The two fixes pending in #727 and #728 are included
so the cut merges after them.

The model recommendation entry described the cheap-tier ranking that #724
replaced with newest-per-family; it now describes the shipped behaviour.

3.1.2 is a patch release, so everything is filed under bug fixes and
improvements; no feature section. Core::VERSION, package.json and the
UPGRADE.md walkthrough move to 3.1.2 together, as they did for 3.1.1.
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