aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-12-30 03:24:54 +0100
committerKim Alvefur <zash@zash.se>2018-12-30 03:24:54 +0100
commit2d28fb93b4a1cf562cd5eb314279e0bb7e349499 (patch)
tree454a032a4af4b3976fb9eaf353652674b2ee6964 /util
parent92445d93df5e5f7d6933c706dd8e60f4e54e0d7c (diff)
downloadprosody-2d28fb93b4a1cf562cd5eb314279e0bb7e349499.tar.gz
prosody-2d28fb93b4a1cf562cd5eb314279e0bb7e349499.zip
util.promise: Remove references to callbacks after settling promise
This is to help the garbage collector.
Diffstat (limited to 'util')
-rw-r--r--util/promise.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/util/promise.lua b/util/promise.lua
index 07c9c4dc..0b182b54 100644
--- a/util/promise.lua
+++ b/util/promise.lua
@@ -49,6 +49,9 @@ local function promise_settle(promise, new_state, new_next, cbs, value)
for _, cb in ipairs(cbs) do
cb(value);
end
+ -- No need to keep references to callbacks
+ promise._pending_on_fulfilled = nil;
+ promise._pending_on_rejected = nil;
return true;
end