Open Bug 1512780 Opened 6 years ago Updated 2 years ago

MozPromise shouldn't require callbacks to return a MozPromise to be chainable

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

People

(Reporter: jya, Unassigned)

Details

https://searchfox.org/mozilla-central/rev/ff46b36ac2ebb243ec95fdab01340391963d62e5/xpcom/threads/MozPromise.h#121-123 The documentation states: If the resolve/reject callback returns void, the * completion promise is resolved/rejected with the same value that was * passed to the callback. That is, you should be able to do something like: RefPtr<GenericPromise> p = GenericPromise::CreateAndResolve(true, __func__); return p->Then(mThread, []() {}, []() {}); however, this fails with: "The resolve/reject callback needs to return a RefPtr<MozPromise> in order to do promise chaining." I believe this is a regression, and it used to work. This can be particularly useful when you want to easily retain an object alive for the duration of the promise: e.g. RefPtr<GenericPromise> p = GenericPromise::CreateAndResolve(true, __func__); RefPtr<blah> kungFuDeathGrip = object; return p->Then(mThread, [kungFuDeathGrip]() {}, [kungFuDeathGrip]() {});
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.