Description
Promise<T> and Promise<void> enqueue a listener whenever the Promise is not already settled with that listener's matching outcome. Adding a rejection listener to an already-resolved Promise—or a resolution listener to an already-rejected Promise—therefore retains the callback and everything it captures until the Promise itself is destroyed, even though that callback can never run.
This is the C++ Promise implementation; open PR #1441 concerns the separate Android JPromise implementation.
Expected behavior
Listeners should be queued only while a Promise is pending. A listener for an impossible outcome on an already-settled Promise should be discarded immediately.
Description
Promise<T>andPromise<void>enqueue a listener whenever the Promise is not already settled with that listener's matching outcome. Adding a rejection listener to an already-resolved Promise—or a resolution listener to an already-rejected Promise—therefore retains the callback and everything it captures until the Promise itself is destroyed, even though that callback can never run.This is the C++ Promise implementation; open PR #1441 concerns the separate Android
JPromiseimplementation.Expected behavior
Listeners should be queued only while a Promise is pending. A listener for an impossible outcome on an already-settled Promise should be discarded immediately.