From 2bb35bbad6422ba3884d3ab7c21805ad10075804 Mon Sep 17 00:00:00 2001 From: Andrey Sudiev Date: Fri, 15 Jun 2018 16:44:08 +0300 Subject: [PATCH] Fix memory leak by unset cancellers --- .../src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php b/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php index f118a33..6245a92 100644 --- a/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php +++ b/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php @@ -111,6 +111,7 @@ public function await($promise = null, $unwrap = false) if (null === $promise) { Deferred::runQueue(); SyncPromise::runQueue(); + $this->cancellers = []; return null; } $promiseAdapter = $this->getWebonyxPromiseAdapter(); @@ -133,6 +134,8 @@ public function await($promise = null, $unwrap = false) throw $exception; } + $hash = spl_object_hash($promise); + unset($this->cancellers[$hash]); return $resolvedValue; } @@ -146,6 +149,7 @@ public function cancel($promise) throw new \InvalidArgumentException(sprintf('The "%s" method must be called with a compatible Promise.', __METHOD__)); } $canceller = $this->cancellers[$hash]; + unset($this->cancellers[$hash]); $adoptedPromise = $promise; if ($promise instanceof Promise) { $adoptedPromise = $promise->adoptedPromise;