Skip to content

Add emscripten_promise_await_unchecked API#26954

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:emscripten_promise_await_unchecked
May 15, 2026
Merged

Add emscripten_promise_await_unchecked API#26954
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:emscripten_promise_await_unchecked

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented May 14, 2026

This works with ASYNCIFY like the existing emscripten_promise_await but is a lot simpler since it only handles the fulfilled case.

In this case we can simple return the result directly without needing to allocate a em_promise_result_t struct to deal with the out param (i.e. no memory access needed).

This can be useful in cases where we don't want to handle the rejections case.

Split out from #26947

@sbc100 sbc100 requested review from kripken and tlively May 14, 2026 20:45
@sbc100 sbc100 force-pushed the emscripten_promise_await_unchecked branch from 953780e to 97d16bd Compare May 14, 2026 20:48
@sbc100 sbc100 requested a review from dschuff May 14, 2026 20:48
@sbc100
Copy link
Copy Markdown
Collaborator Author

sbc100 commented May 14, 2026

I'm not particularly attached to this name. We could also do with emscripten_promise_await_resolved?

@sbc100 sbc100 force-pushed the emscripten_promise_await_unchecked branch from 97d16bd to 23cfec2 Compare May 14, 2026 22:13
Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I like the "unchecked" name.

@sbc100 sbc100 force-pushed the emscripten_promise_await_unchecked branch from 23cfec2 to 2d979ec Compare May 14, 2026 23:04
This works with ASYNCIFY like the existing `emscripten_promise_await`
but is a lot simpler since it only handles the fulfilled case.

In this case we can simple return the result directly without needing
to allocate a `em_promise_result_t` struct to deal with the out param
(i.e. no memory access needed).

This can be useful in cases where we don't want to handle the rejections
case.
@sbc100 sbc100 force-pushed the emscripten_promise_await_unchecked branch from 2d979ec to fb3de64 Compare May 15, 2026 00:38
@sbc100 sbc100 merged commit 478a1af into emscripten-core:main May 15, 2026
2 of 15 checks passed
@sbc100 sbc100 deleted the emscripten_promise_await_unchecked branch May 15, 2026 00:38
sbc100 added a commit that referenced this pull request May 15, 2026
sbc100 added a commit to sbc100/emscripten that referenced this pull request May 15, 2026
This was broken by emscripten-core#26954 but not covered by CI because we run the
`other` testsuite with the emsdk version of node that doesn't support
wasm64.
sbc100 added a commit that referenced this pull request May 15, 2026
This was broken by #26954 but not covered by CI because we run the
`other` testsuite with the emsdk version of node that doesn't support
wasm64.

Without this change the wasm64 variant complains because it tried to
case the return value of this function to a BigInt (pointer) before
returning to Wasm.
sbc100 added a commit that referenced this pull request May 15, 2026
Of course, I should really have waited until all CI tests passed when I
landed #26954!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants