# HG changeset patch # User Matthew Wild # Date 1679573693 0 # Node ID 2c17151ed21b60cf56274a631bfb6c0418b6e40e # Parent 433a1f36d0d32918c57721abc776c8d5e6383b9a client: Fix timeout handling Previously, the timeout handler would fire an error that would get caught and logged by the timer code. However that error never reached the upper levels of scansion, leading to the whole thing just hanging. Now we just trigger resumption of the async runner, and throw the error from there if we haven't received the stanza yet. With this change, timeouts are now correctly handled and reported as failures. diff -r 433a1f36d0d3 -r 2c17151ed21b scansion/objects/client.lua --- a/scansion/objects/client.lua Thu Mar 23 11:51:31 2023 +0000 +++ b/scansion/objects/client.lua Thu Mar 23 12:14:53 2023 +0000 @@ -107,7 +107,12 @@ end client.stream:hook("stanza", stanza_handler, 100); verse.add_task(client.stanza_timeout or default_stanza_timeout, function () - if have_received_stanza then return; end + done(); + end); + client.stream.conn:resume(); + wait(); + + if not have_received_stanza then if expected_stanza then client.log("TIMEOUT waiting for %s", expected_stanza) local e = new_error("stanza-timeout", { text = "Timed out waiting for stanza" }); @@ -117,9 +122,7 @@ client.log("Good - no stanzas were received (expected)"); done(); end - end); - client.stream.conn:resume(); - wait(); + end end; disconnects = function (client)