Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX: "TaskFailure: use Amp\Parallel\Worker\TaskException::getWorkerTrace() for the stack trace in the worker" #101

Closed
staabm opened this issue Feb 25, 2020 · 3 comments

Comments

@staabm
Copy link
Member

staabm commented Feb 25, 2020

with my current code in PHP-CS-Fixer/PHP-CS-Fixer#4838 at commit
7603b4b I am running into the following Exception:

$ time php php-cs-fixer fix ../redaxo/redaxo/src/core/
Loaded config default from "C:\xampp7.1.4\htdocs\PHP-CS-Fixer\.php_cs.dist".
Paths from configuration file have been overridden by paths provided as command arguments.
string(30) "PhpCsFixer\Linter\PooledLinter"

In TaskFailure.php line 69:

  Uncaught Amp\Parallel\Sync\SerializationException in worker with message "The given data cannot be
   sent because it is not serializable." and code "0"; use Amp\Parallel\Worker\TaskException::getWorkerTrace() for the stack trace in the worker


In TaskFailure.php line 69:

  Uncaught Exception in worker with message "Serialization of 'Closure' is not allowed" and code "0"
  ; use Amp\Parallel\Worker\TaskException::getWorkerTrace() for the stack trace in the worker


fix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [
--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--diff-format DIFF-FORMAT] [--format FOR
MAT] [--stop-on-violation] [--show-progress SHOW-PROGRESS] [--] [<path>...]


real    0m19.519s
user    0m0.000s
sys     0m0.061s

I am not sure what this error is trying to tell me:

use Amp\Parallel\Worker\TaskException::getWorkerTrace() for the stack trace in the worker

nowhere in the codebase I am using TaskFailure or TaskException. where do I need to catch/handle the mentioned TaskFailure (or TaskException?) to invoke getWorkerTrace() on it?

@staabm
Copy link
Member Author

staabm commented Feb 25, 2020

side-note: the suggested message seems to hint about a method call which is deprecated.

TaskException::getWorkerTrace() tells me to use getOriginalTraceAsString() instead

@trowski
Copy link
Member

trowski commented Feb 25, 2020

Worker::enqueue() returns a promise that can only fail with an instance of TaskFailureException or TaskFailureError, which both implement TaskFailureThrowable. The exception thrown by a Task is wrapped in a TaskFailure object and sent back to the parent, then re-thrown as one of those two classes.

I'm not sure you're actually using 1.3, as the exception message should now suggest using getOriginalTrace().

@trowski
Copy link
Member

trowski commented Dec 30, 2022

Closing as this issue is old and has not received further feedback. Please try v2 of this library when you get a chance, the API and error handling has been improved significantly.

@trowski trowski closed this as completed Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants