Skip to content

Fix: a failing pool task is reported again as an unhandled future (better exception stack traces) - #14595

Merged
alies-dev merged 2 commits into
vimeo:masterfrom
alies-dev:fix/pool-failed-task-reported-once
Nov 21, 2026
Merged

alies-dev merged 2 commits into
vimeo:masterfrom
alies-dev:fix/pool-failed-task-reported-once

Conversation

@alies-dev

@alies-dev alies-dev commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

When a task of a worker pool fails (for example a plugin hook throwing in a scan worker), Psalm reports the failure, then reports it again wrapped in UnhandledFutureError and UncaughtThrowable from the event loop.

Before (--threads=2 on 600 files, a plugin throwing in afterClassLikeVisit for one class)

Uncaught Amp\Parallel\Worker\TaskFailureException: RuntimeException thrown in context with message "Boom while scanning C300" and code "0" in plugin/BoomPlugin.php:10
Next Amp\Future\UnhandledFutureError: Unhandled future: Amp\Parallel\Worker\TaskFailureException: "RuntimeException thrown in context with message "Boom while scanning C300" and code "0" in plugin/BoomPlugin.php:10 ...
Next Revolt\EventLoop\UncaughtThrowable: Uncaught Amp\Future\UnhandledFutureError thrown in event loop callback Amp\Internal\FutureState::{closure:Amp\Internal\FutureState::__destruct():59} ...

After

Uncaught Amp\Parallel\Worker\TaskFailureException: RuntimeException thrown in context with message "Boom while scanning C300" and code "0" in plugin/BoomPlugin.php:10

When a task of a worker pool failed, Pool::run() reported the failure and
then reported it again: the futures it derived from the task's future
(task-done callback, slow-task timer, progress counter, message pump) were
never observed, and destroying them raised UnhandledFutureError and
UncaughtThrowable from the event loop.

Keep those futures and await them with the task futures, so a failure is
thrown once. When submit() throws before the await (a worker that cannot
start kills the pool, and the tasks already submitted fail with it), ignore
them, as the thrown error already says why. The pump's channel-closing
future is ignored too: the task future awaited in run() carries the failure.
@alies-dev
alies-dev marked this pull request as ready for review November 21, 2026 23:36
@alies-dev alies-dev self-assigned this Nov 21, 2026
@alies-dev alies-dev added the release:internal The PR will be included in 'Internal changes' section of the release notes label Nov 21, 2026
@alies-dev alies-dev changed the title Fix: a failing pool task is reported again as an unhandled future Fix: a failing pool task is reported again as an unhandled future (better exception stack traces) Nov 21, 2026
- Drop the submit() failure path, the ContextFactory parameter and the tests and helpers that only served it.
- One test runs a failing task with a message handler and a task-done closure, so it covers the derived futures and the message pump.
@alies-dev
alies-dev merged commit 472dc11 into vimeo:master Nov 21, 2026
70 of 71 checks passed
@alies-dev
alies-dev deleted the fix/pool-failed-task-reported-once branch November 21, 2026 23:40
@github-actions

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: unchanged

Project Memory (MB) Wall (s) Issues Weighted (types) Taint
✅ laravel 1 749 90.2 $\color{gray}{\textsf{+1.2\%}}$ 25 907 53 460 682
✅ symfony 3 599 246.9 $\color{gray}{\textsf{+0.3\%}}$ 50 610 98 403 1 528
✅ doctrine-orm 380 20.7 $\color{gray}{\textsf{+0.1\%}}$ 3 481 6 143 0
✅ psl 617 26.7 $\color{gray}{\textsf{+0.5\%}}$ 1 375 5 615 1
✅ phpunit 455 10.8 $\color{gray}{\textsf{+0.7\%}}$ 1 731 3 410 18
✅ php-parser 226 7.3 $\color{gray}{\textsf{+0.4\%}}$ 17 154 21 245 0
✅ tempest 895 19.9 $\color{gray}{\textsf{+0.1\%}}$ 5 047 10 528 252
✅ amphp-amp 45 1.4 29 49 0
✅ webmozarts-assert 273 4.4 $\color{gray}{\textsf{+0.7\%}}$ 577 2 720 0
✅ guzzle-promises 44 1.5 155 434 2
✅ monolog 135 5.3 $\color{gray}{\textsf{+0.4\%}}$ 913 2 479 10
✅ drupal 4 842 150.9 $\color{gray}{\textsf{-0.6\%}}$ 97 591 169 293 583
Total 13 260 586.0 $\color{gray}{\textsf{+0.2\%}}$ 204 570 373 779 3 076
How to read this table
  • Memory: Psalm's own peak figure, threads=1. More than +5 % fails, unless the PR changes composer.json.
  • Wall: base and head run on the same runner; ±10 % is noise. Above +20 % warns, never fails. re-run: a reversed second run was taken and the faster kept.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base.
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1). Taint and dead-code issues are not weighed. The projects' own code is pinned and their dependencies resolve identically for base and head, so a change means Psalm reports more, fewer or differently serious issues. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (findUnusedCode). More is red, fewer is green.
  • Total: sum over the projects compared on both sides. Thresholds apply per project, not to the total.
  • Colors: $\color{red}{\textsf{red}}$ past a fail or warn threshold (or more issues), $\color{green}{\textsf{green}}$ an improvement past noise (or fewer issues), $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Performance: regressed if a head run crashed or timed out or a memory or wall delta is red, else improved if one is green, else unchanged. Its icon is the check result: ❌ fail · ⚠️ warn · ✅ pass; the icon next to each project is that project's result, 💥 = not comparable: base crashed or timed out (counts as ⚠️).
  • Types (heading): direction of the total weighted change, increased · decreased · unchanged. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the check.

head 7db8059 · base 0b1d9ca (merge-base) · workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:internal The PR will be included in 'Internal changes' section of the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant