Implement emscripten_promise_all_settled in promise.h#19152
Conversation
This is like `emscripten_promise_all`, but always fulfills and separately reports whether each input promise is fulfilled or rejected.
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
| promise: Promise.allSettled(promises).then((results) => { | ||
| if (resultBuf) { | ||
| for (var i = 0; i < size; i++) { | ||
| let baseOffset = i * {{{ C_STRUCTS.em_settled_result_t.__size__ }}}; |
There was a problem hiding this comment.
I don't think we using let yet in our library code. Can you stick to var?
|
Any ideas for how to work around this closure error? |
|
I just decided to suppress it for now. LMK if there's a better solution. |
|
Yikes, it looks like some build modes remove the newline after the suppression comment, causing a new error. @sbc100, any ideas for workarounds? |
I've not seen that before from the |
| {{{ makeSetValue('resultBuf', 'resultOffset', 'reject', 'i32') }}}; | ||
| // Closure can't type `reason` in some contexts | ||
| /** @suppress {checkTypes} */ | ||
| {{{ makeSetValue('resultBuf', 'valueOffset', 'results[i].reason', '*') }}}; |
There was a problem hiding this comment.
So these promises only ever get rejected or fullfilled with Numbers? What happens if one of them is rejected to fulfilled with something that is not a number?
There was a problem hiding this comment.
Yeah, they're always fulfilled or rejected with pointers because the fulfill values and reject reasons are always represented as void* in the C API.
There was a problem hiding this comment.
I think you can do something like this: var reason = /** @type {number} */ results[i].reason;
There was a problem hiding this comment.
Is there a good way to generalize that for wasm64?
There was a problem hiding this comment.
We use number for pointer in wasm64 and wasm32 so it should just work.

This is like
emscripten_promise_all, but always fulfills and separatelyreports whether each input promise is fulfilled or rejected.