aboutsummaryrefslogtreecommitdiffstats
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
commit93c5ebb743337c82103ea94166065106a9f5b641 (patch)
tree454a032a4af4b3976fb9eaf353652674b2ee6964
parent26e3090de67f9fc5152c764122b7a62d3d9534ac (diff)
downloadprosody-93c5ebb743337c82103ea94166065106a9f5b641.tar.gz
prosody-93c5ebb743337c82103ea94166065106a9f5b641.zip
util.promise: Remove references to callbacks after settling promise
This is to help the garbage collector.
-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