Skip to content

Kill connection invalid exception #75

@root-aza

Description

@root-aza

Repoduce:

<?php

declare(strict_types=1);

namespace App\Transport\ManualBank\UI\Console;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use Thesis\Amqp\Client;
use Thesis\Amqp\DeliveryMessage;
use Throwable;

#[AsCommand('manual-bank:test-consume', description: 'Init queue for Manual Bank')]
final readonly class TestConsumeCommand
{
    public function __construct(
        private Client $client,
    ) {}


    /**
     * @throws Throwable
     */
    public function __invoke(SymfonyStyle $output): int
    {
        $channel = $this->client->channel();
        $channel->qos(prefetchCount: 1);

        /** @var DeliveryMessage $message */
        foreach ($channel->consumeIterator('manaul-bank.income.queue', 'manaul-bank.income') as $message) {
            dump($message);


            $message->ack();
        }


        return Command::SUCCESS;
    }
}

Stacktrace:

log
                                                                                                                                                         
  [Error]                                                                                                                                                 
  Event loop terminated without resuming the current suspension (the cause is either a fiber deadlock, or an incorrectly unreferenced/canceled watcher):  
                                                                                                                                                          
  #0 /app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:625 Fiber::suspend()                                                         
  #1 Revolt\EventLoop\Internal\AbstractDriver->{closure:Revolt\EventLoop\Internal\AbstractDriver::createCallbackFiber():565}()                            
                                                                                                                                                          
  #0 /app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:625 Fiber::suspend()                                                         
  #1 Revolt\EventLoop\Internal\AbstractDriver->{closure:Revolt\EventLoop\Internal\AbstractDriver::createCallbackFiber():565}()                            
                                                                                                                                                          

Exception trace:
  at /app/vendor/revolt/event-loop/src/EventLoop/Internal/DriverSuspension.php:145
 Revolt\EventLoop\Internal\DriverSuspension->suspend() at /app/vendor/amphp/pipeline/src/Internal/QueueState.php:128
 Amp\Pipeline\Internal\QueueState->continue() at /app/vendor/amphp/pipeline/src/Internal/ConcurrentQueueIterator.php:55
 Amp\Pipeline\Internal\ConcurrentQueueIterator->getIterator() at /app/vendor/thesis/amqp/src/Internal/QueueIterator.php:81
 Thesis\Amqp\Internal\QueueIterator->getIterator() at /app/src/Transport/ManualBank/UI/Console/TestConsumeCommand.php:31
 App\Transport\ManualBank\UI\Console\TestConsumeCommand->__invoke() at /app/vendor/symfony/console/Command/InvokableCommand.php:52
 Symfony\Component\Console\Command\InvokableCommand->__invoke() at /app/vendor/symfony/console/Command/Command.php:315
 Symfony\Component\Console\Command\Command->run() at /app/vendor/symfony/console/Application.php:1110
 Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/framework-bundle/Console/Application.php:123
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /app/vendor/symfony/console/Application.php:359
 Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/framework-bundle/Console/Application.php:77
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:194
 Symfony\Component\Console\Application->run() at /app/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /app/vendor/autoload_runtime.php:29
 require_once() at /app/bin/console:13

manual-bank:test-consume


Fatal error: Uncaught Thesis\Amqp\Exception\ConnectionIsClosed in /app/vendor/thesis/amqp/src/Internal/Io/Buffer.php on line 167

Thesis\Amqp\Exception\ConnectionIsClosed:  in /app/vendor/thesis/amqp/src/Internal/Io/Buffer.php on line 167

Call Stack:
    0.3353    5068960   1. {fiber:FFFF989D7940}() /app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:503
    0.3353    5085344   2. Revolt\EventLoop\Driver\EvDriver->{closure:/app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:565-627}() /app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:503
    9.0333    5757312   3. Revolt\EventLoop\Driver\EvDriver->invokeMicrotasks() /app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:567
    9.0333    5756848   4. {closure:/app/vendor/amphp/amp/src/functions.php:23-37}() /app/vendor/revolt/event-loop/src/EventLoop/Internal/AbstractDriver.php:430
    9.0333    5756928   5. Thesis\Amqp\Client->{closure:/app/vendor/thesis/amqp/src/Client.php:69-73}() /app/vendor/amphp/amp/src/functions.php:33
    9.0334    5757008   6. Thesis\Amqp\Internal\Io\AmqpConnectionFactory->close() /app/vendor/thesis/amqp/src/Client.php:71
    9.0334    5757232   7. Thesis\Amqp\Internal\Io\AmqpConnection->writeFrame() /app/vendor/thesis/amqp/src/Internal/Io/AmqpConnectionFactory.php:83
    9.0334    5757496   8. Thesis\Amqp\Internal\Io\Buffer->writeTo() /app/vendor/thesis/amqp/src/Internal/Io/AmqpConnection.php:85

Video proof:

Screen.Recording.2025-10-27.at.16.18.35.mov

Environment:

php

packages: thesis/amqp: 1.0.2

PHP 8.4.10 (cli) (built: Jul  3 2025 22:55:39) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.10, Copyright (c), by Zend Technologies
    with Xdebug v3.4.6, Copyright (c) 2002-2025, by Derick Rethans
[PHP Modules]
amqp
bcmath
Core
ctype
curl
date
dom
ev
FFI
fileinfo
filter
gd
gmp
grpc
hash
iconv
intl
json
libxml
mbstring
mysqlnd
openssl
opentelemetry
pcntl
pcov
pcre
PDO
pdo_pgsql
pdo_sqlite
Phar
posix
protobuf
random
rdkafka
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions