Skip to content

Commit 0cf34dc

Browse files
authored
Merge pull request #191 from clue-labs/trace
Fix invalid references in exception stack trace
2 parents 6d38296 + bcbea0d commit 0cf34dc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/Query/RetryExecutor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ public function tryQuery(Query $query, $retries)
5656

5757
// Exception trace arguments are not available on some PHP 7.4 installs
5858
// @codeCoverageIgnoreStart
59-
foreach ($trace as &$one) {
59+
foreach ($trace as $ti => $one) {
6060
if (isset($one['args'])) {
61-
foreach ($one['args'] as &$arg) {
61+
foreach ($one['args'] as $ai => $arg) {
6262
if ($arg instanceof \Closure) {
63-
$arg = 'Object(' . \get_class($arg) . ')';
63+
$trace[$ti]['args'][$ai] = 'Object(' . \get_class($arg) . ')';
6464
}
6565
}
6666
}

tests/Query/RetryExecutorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ public function queryShouldStopRetryingAfterSomeAttempts()
9494
$exception = $reason;
9595
});
9696

97-
/** @var \RuntimeException $exception */
97+
assert($exception instanceof \RuntimeException);
9898
$this->assertInstanceOf('RuntimeException', $exception);
9999
$this->assertEquals('DNS query for igor.io (A) failed: too many retries', $exception->getMessage());
100+
$this->assertEquals(0, $exception->getCode());
101+
$this->assertInstanceOf('React\Dns\Query\TimeoutException', $exception->getPrevious());
102+
$this->assertNotEquals('', $exception->getTraceAsString());
100103
}
101104

102105
/**

0 commit comments

Comments
 (0)