From e7a01c7bed53d79397f9889f2efbd7c9f626ae3c Mon Sep 17 00:00:00 2001 From: Eryn Lynn Date: Mon, 24 Aug 2020 13:34:36 -0400 Subject: [PATCH] Fix #39 --- CHANGELOG.md | 1 + lib/init.lua | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 839d21c..fd28dcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixed - Make `Promise.is` work with promises from old versions of the library (#41) - Make `Promise.delay` properly break out of the current loop (#40) +- Allow upvalues captured by queued callbacks to be garbage collected when the Promise resolves by deleting the queues when the Promise settles (#39) ## [3.0.0] - 2020-08-17 ### Changed diff --git a/lib/init.lua b/lib/init.lua index 16ff901..392f4e7 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -1292,6 +1292,10 @@ function Promise.prototype:_finalize() coroutine.wrap(callback)(self._status) end + self._queuedFinally = nil + self._queuedReject = nil + self._queuedResolve = nil + -- Clear references to other Promises to allow gc if not Promise.TEST then self._parent = nil