Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ private function openSocketIo($filename, $flags = null)
$deferred->reject(new \RuntimeException('No connection detected'));
});

$process->on('exit', function () use ($deferred, $server, $timeout) {
$this->loop->cancelTimer($timeout);
if (is_resource($server)) {
$this->loop->removeReadStream($server);
fclose($server);
}

$deferred->reject(new \RuntimeException('Database process died while setting up connection'));
});

$this->loop->addReadStream($server, function () use ($server, $timeout, $filename, $flags, $deferred, $process) {
// accept once connection on server socket and stop server socket
$this->loop->cancelTimer($timeout);
Expand Down
6 changes: 4 additions & 2 deletions tests/FunctionalFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public function testOpenReturnsPromiseWhichRejectsWithExceptionWhenPathIsInvalid
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});

$this->expectOutputString('Error: Unable to open database: unable to open database file' . PHP_EOL);
// Unable to open database: unable to open database file
// Unable to open database: bad parameter or other API misuse (only between PHP 7.4.0 and PHP 7.4.7 as per https://3v4l.org/9SjgK)
$this->expectOutputRegex('/^' . preg_quote('Error: Unable to open database: ', '/') . '.*$/');
Loop::run();
}

Expand All @@ -82,7 +84,7 @@ public function testOpenReturnsPromiseWhichRejectsWithExceptionWhenExplicitPhpBi
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});

$this->expectOutputString('Error: No connection detected' . PHP_EOL);
$this->expectOutputString('Error: Database process died while setting up connection' . PHP_EOL);
Loop::run();
}
}