Skip to content

context: Only warn about unhandled promises when the job queue is empty

Marco Trevisan requested to merge 3v1n0/gjs:unhandled-promises-wait into master

A promise rejection may be reported as not handled even though it's going to be handled by a later added promise. In such case we were correctly be informed about this via unregister_unhandled_promise_rejection(), but given that since commit 4446ee7f we were immediately warning about unhandled promise rejections our unhandled rejections stack trace list was already cleared.

To avoid this, let's just wait for the job queue to be fully processed and do this only while the promise dispatcher is running, so that we won't accidentally clear the unhandled rejections list, until those have been fully processed.

By doing this we are both avoiding misbehaving on the said case, and we don't regress by keeping the cases handled by #417 (closed) still valid.

Added tests to cover both a normal rejection case and the one that was previously leading to a crash (assertion error).

Fixes: #466 (closed)

Edited by Marco Trevisan

Merge request reports