I found what appears to be a bug (or at least unfortunate oversight) in query control flow. Say you have 2 queries --
query1:
await new Promise(r => setTimeout(r, 1000));
console.log("ping");
query2:
await query1.trigger();
console.log("done");
and query1 has the following script as an event handler on success:
await new Promise(r => setTimeout(r, 1000));
console.log("pong")
If you run query2, you would expect to see
ping
pong
done
in the console, as query2 blocks on query1 immediately. Then, query1 waits a second before printing "ping". Next, it's success handler fires, waits another second, and prints "pong". Finally, control returns to query2 where it prints "done". Instead, I see
ping
done
pong
in the console because control erroneously returns to query2 before all event handlers on query1 exit. The first control flow scheme should be an option in the trigger method and advanced options to at least avoid breaking existing apps.