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

SQS Worker sends a Throwable to DetectsLostConnections trait's causedByLostConnection which only accepts an Exception #19588

Closed
JessicaMulein opened this issue Jun 13, 2017 · 2 comments

Comments

@JessicaMulein
Copy link

  • Laravel Version: 5.4.25
  • PHP Version: PHP 7.1.3-3+deb.sury.org~xenial+1 (cli) (built: Mar 25 2017 14:00:03) ( NTS )

Description:

I have an SQS Queue Worker that is getting an unknown connection problem during getNextJob() and yielding a Throwable.

vendor/laravel/framework/src/Illuminate/Queue/Worker.php:249

        } catch (Throwable $e) {
            $this->exceptions->report(new FatalThrowableError($e));

            $this->stopWorkerIfLostConnection($e);
        }

goes to vendor/laravel/framework/src/Illuminate/Queue/Worker.php:285

    protected function stopWorkerIfLostConnection($e)
    {
        if ($this->causedByLostConnection($e)) {
            $this->shouldQuit = true;
        }
    }

goes to vendor/laravel/framework/src/Illuminate/Database/DetectsLostConnections.php:16

trait DetectsLostConnections
{
    /**
     * Determine if the given exception was caused by a lost connection.
     *
     * @param  \Exception  $e
     * @return bool
     */
    protected function causedByLostConnection(Exception $e)
    {

which yields a failure:

[2017-06-13 11:32:49] test.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Illuminate\Queue\Worker::causedByLostConnection() must be an instance of Exception, instance of Error given, called in /opt/test-processor/vendor/laravel/framework/src/Illuminate/Queue/Worker.php on line 287 in /opt/test-processor/vendor/laravel/framework/src/Illuminate/Database/DetectsLostConnections.php:16
Stack trace:
#0 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(287): Illuminate\Queue\Worker->causedByLostConnection(Object(Error))


#1 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(252): Illuminate\Queue\Worker->stopWorkerIfLostConnection(Object(Error))
#2 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(104): Illuminate\Queue\Worker->getNextJob(Object(ClearanceJobs\Queue\SqsBatchQueue), 'test-batch-q...')


{
    "_readme": [
        "This file locks the dependencies of your project to a known state",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
        "This file is @generated automatically"
    ],
    "content-hash": "a7b63af1c266cac15784360fab5c05f3",
    "packages": [
        {
            "name": "aws/aws-sdk-php",
            "version": "3.29.3",
            "source": {
                "type": "git",
                "url": "https://github.com/aws/aws-sdk-php.git",
                "reference": "f375f08b77da1a1dbf68e4a0384d65e7d9018639"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/f375f08b77da1a1dbf68e4a0384d65e7d9018639",
                "reference": "f375f08b77da1a1dbf68e4a0384d65e7d9018639",
                "shasum": ""
            },
            "require": {
                "guzzlehttp/guzzle": "^5.3.1|^6.2.1",
                "guzzlehttp/promises": "~1.0",
                "guzzlehttp/psr7": "^1.4.1",
                "mtdowling/jmespath.php": "~2.2",
                "php": ">=5.5"
            },
            "require-dev": {
                "andrewsville/php-token-reflection": "^1.4",
                "aws/aws-php-sns-message-validator": "~1.0",
                "behat/behat": "~3.0",
                "doctrine/cache": "~1.4",
                "ext-dom": "*",
                "ext-json": "*",
                "ext-openssl": "*",
                "ext-pcre": "*",
                "ext-simplexml": "*",
                "ext-spl": "*",
                "nette/neon": "^2.3",
                "phpunit/phpunit": "^4.8.35|^5.4.0",
                "psr/cache": "^1.0"
/laravel
#3 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('sqs', 'test-batch-q...', Object(Illuminate\Queue\WorkerOptions))
#4 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(84): Illuminate\Queue\Console\WorkCommand->runWorker('sqs', 'test-batch-q...')
#5 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#6 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#7 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#9 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#10 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#11 /opt/test-processor/vendor/symfony/console/Command/Command.php(264): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#12 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#13 /opt/test-processor/vendor/symfony/console/Application.php(869): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /opt/test-processor/vendor/symfony/console/Application.php(223): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /opt/test-processor/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /opt/test-processor/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /opt/test-processor/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 {main}
@JessicaMulein
Copy link
Author

The fix seems to be just taking the type out of the function signature, and optionally checking that $e is one of those two types before trying to read $e->getMessage();

@themsaid
Copy link
Member

Thank you, fixed in #19591 :)

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

No branches or pull requests

2 participants