Small workaround

This commit is contained in:
Daniil Gentili 2019-06-25 18:11:42 +02:00
parent 214fc0d0f9
commit eafa19eb4e

View File

@ -312,7 +312,15 @@ trait ResponseHandler
if (isset($request['promise'])) { if (isset($request['promise'])) {
$promise = $request['promise']; $promise = $request['promise'];
unset($request['promise']); unset($request['promise']);
$promise->fail($data); try {
$promise->fail($data);
} catch (\Error $e) {
if (strpos($e->getMessage(), "Promise has already been resolved") !== 0) {
throw $e;
}
$this->logger->logger("Got promise already resolved error", \danog\MadelineProto\Logger::FATAL_ERROR);
}
} else { } else {
$this->logger->logger('Rejecting: already got response for '.(isset($request['_']) ? $request['_'] : '-')); $this->logger->logger('Rejecting: already got response for '.(isset($request['_']) ? $request['_'] : '-'));
$this->logger->logger("Rejecting: $data"); $this->logger->logger("Rejecting: $data");
@ -576,7 +584,14 @@ trait ResponseHandler
if (isset($this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise'])) { // This should not happen but happens, should debug if (isset($this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise'])) { // This should not happen but happens, should debug
$promise = $this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise']; $promise = $this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise'];
unset($this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise']); unset($this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise']);
$promise->resolve($response); try {
$promise->resolve($response);
} catch (\Error $e) {
if (strpos($e->getMessage(), "Promise has already been resolved") !== 0) {
throw $e;
}
$this->logger->logger("Got promise already resolved error", \danog\MadelineProto\Logger::FATAL_ERROR);
}
} }
} }
)()); )());