# HG changeset patch # User Kim Alvefur # Date 1632507136 -7200 # Node ID a9ad287c3388ccd1005f40c4538659a1dbca9e74 # Parent 0375ef78ed642c99fba920f3917947d06e3d4dbf core.moduleapi: Filter out unrelated direct replies to module:send_iq This is primarily something that happens with an internal query to mod_mam, which calls origin.send() several times with results, leading to the first such result being treated as the final response and resolving the promise. Now, these responses pass trough to the underlying origin.send(), where they can be caught. Tricky but not impossible. For remote queries, it's even trickier, you would likely need to bind a resource or similar. diff -r 0375ef78ed64 -r a9ad287c3388 core/moduleapi.lua --- a/core/moduleapi.lua Fri Sep 24 18:39:28 2021 +0200 +++ b/core/moduleapi.lua Fri Sep 24 20:12:16 2021 +0200 @@ -439,7 +439,10 @@ local wrapped_origin = setmetatable({ -- XXX Needed in some cases for replies to work correctly when sending queries internally. send = function (reply) - resolve({ stanza = reply }); + if reply.name == stanza.name and reply.attr.id == stanza.attr.id then + resolve({ stanza = reply }); + end + return (origin or hosts[self.host]).send(reply) end; }, { __index = origin or hosts[self.host];