Bug 1762233 Comment 3 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

(In reply to Kagami :saschanaz from comment #2)
> The current implementation cares very much about Promise allocations. We can remove them, at least.

I actually took a look at this, because I thought it would be easy enough to make a `Promise::CreateInfallible` . Turns out, not the case! 

There are actually two ways that `Promise::Create` can throw: 

1. [Allocating the `JS::PromiseObject`](https://searchfox.org/mozilla-central/rev/711e1cea1cb584057c50aac0a26a3f7c969eda66/dom/promise/Promise.cpp#302-307); this is the OOM Condition I thought we could avoid handling.
2. [Running AutoJSAPI::init](https://searchfox.org/mozilla-central/rev/711e1cea1cb584057c50aac0a26a3f7c969eda66/dom/promise/Promise.cpp#296-300). 

(Technically, there's a third, if you pass it a nullptr global, but I didn't consider that here) 

While I'm reasonably comfortable crashing on OOM, I'm less comfortable crashing on AutoJSAPI::init failure; I'm not entirely sure the circumstances where it could fail (seems like mostly it's if the global can't return its JSObject... but I I don't know where that happens). 

Having said that, I still think there's improvement we can do here.
(In reply to Kagami :saschanaz from comment #2)
> The current implementation cares very much about Promise allocations. We can remove them, at least.

I actually took a look at this, because I thought it would be easy enough to make a `Promise::CreateInfallible` . Turns out, not the case! 

There are actually two ways that `Promise::Create` can throw: 

1. [Allocating the `JS::PromiseObject`](https://searchfox.org/mozilla-central/rev/711e1cea1cb584057c50aac0a26a3f7c969eda66/dom/promise/Promise.cpp#302-307); this is the OOM Condition I thought we could avoid handling.
2. [Running AutoJSAPI::init](https://searchfox.org/mozilla-central/rev/711e1cea1cb584057c50aac0a26a3f7c969eda66/dom/promise/Promise.cpp#296-300). 

(Technically, there's a third, if you pass it a nullptr global, but I didn't consider that here) 

While I'm reasonably comfortable crashing on OOM, I'm less comfortable crashing on AutoJSAPI::init failure; I'm not entirely sure the circumstances where it could fail (seems like mostly it's if the global can't return its JSObject... but I I don't know where that happens). 

Having said that, I still think there's improvement we can do here.

**Edit**:  It's not clear how we can cleanly do this though.

Back to Bug 1762233 Comment 3