Skip to content

Can not send more queries after 'Not supportted value type' exception #167

@yyydevf

Description

@yyydevf

Hello

I have a bug in v 0.5.* and v0.6.*

While we have an invalid type of argument, we haven't drop current state of mysql, look at example, because exception does not catch

<?php


declare(strict_types=1);

require_once 'vendor/autoload.php';

$connection = $factory->createLazyConnection('root:[email protected]:3306/storage');
$connection->query("update table set value = ?", [new stdClass()]) // Invalid type of object
    ->otherwise(function ($e) use ($connection) {
        return $connection->query("select * from table where id = 1")
            ->then(function ($e) {
                echo 1; // thats never happened
            })
            ->otherwise(function ($e) use ($connection) {
                echo 1; // thats too
            });
    });

Look at this method:

protected function nextRequest($isHandshake = false)

And its body (i do not know how to reply multiple lines of code, sorry, so paste my)

protected function nextRequest($isHandshake = false)
    {
        if (!$isHandshake && $this->phase != self::PHASE_HANDSHAKED) {
            return false;
        }

        if ($this->currCommand === null && !$this->executor->isIdle()) {
            $command = $this->executor->dequeue(); 
            $this->currCommand = $command; // current command set here

            if ($command instanceof AuthenticateCommand) {
                $this->phase = self::PHASE_AUTH_SENT;
                $this->sendPacket($command->authenticatePacket($this->scramble, $this->buffer));
            } else {
                $this->seq = 0;
                $this->sendPacket($this->buffer->buildInt1($command->getId()) . $command->getSql()); // Exception occurs here
            }
        }

        return true;
    }

Exception line never catched and just reject:

throw new \InvalidArgumentException(sprintf('Not supportted value type of %s.', $type));

return \React\Promise\reject($e);

So we are cannot send more queries from its connection, cause do not drop $this->currCommand

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions