Fix Asyncify.handleAsync conflict with PROXY_SYNC_ASYNC#26513
Open
thiblahute wants to merge 1 commit intoemscripten-core:mainfrom
Open
Fix Asyncify.handleAsync conflict with PROXY_SYNC_ASYNC#26513thiblahute wants to merge 1 commit intoemscripten-core:mainfrom
thiblahute wants to merge 1 commit intoemscripten-core:mainfrom
Conversation
Contributor
Author
|
Thanks! Yes, I just saw #26482 landed ppoll support - I've rebased and dropped the ppoll commit. The remaining change here fixes a pre-existing bug in |
sbc100
reviewed
Mar 21, 2026
5089fe8 to
4c3d00b
Compare
sbc100
reviewed
Mar 23, 2026
sbc100
reviewed
Mar 23, 2026
c4ceddb to
e414ec8
Compare
sbc100
reviewed
Mar 23, 2026
sbc100
reviewed
Mar 23, 2026
test/test_core.py
Outdated
| @requires_pthreads | ||
| def test_poll_blocking_asyncify_pthread(self): | ||
| # Only testing ASYNCIFY=1: JSPI's handleAsync is a plain async function | ||
| # and doesn't have this bug. Also, with_asyncify_and_jspi can't be |
Collaborator
There was a problem hiding this comment.
I think we should still test both versions of ASYNCIFY here.
Contributor
Author
There was a problem hiding this comment.
It was failing because of the limitation, getting
FAIL [0.000s]: test_poll_blocking_asyncify_pthread_jspi (test_core.core0)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/project/test/common.py", line 377, in resulting_test
return func(self, *args)
File "/root/project/test/test_core.py", line 257, in metafunc
return func(self, *args, **kwargs)
File "/root/project/test/test_core.py", line 9657, in test_poll_blocking_asyncify_pthread
self.require_pthreads()
File "/root/project/test/common.py", line 467, in require_pthreads
self.fail('no JS engine found capable of running pthreads')
AssertionError: no JS engine found capable of running pthreads
sbc100
reviewed
Mar 23, 2026
When a JS library function has both __proxy:'sync' and __async:'auto', the compiler generates an Asyncify.handleAsync wrapper. When called from the PROXY_SYNC_ASYNC path on the main thread, handleAsync triggers an Asyncify unwind instead of returning a Promise, causing "rtn.then is not a function" in the proxy infrastructure. Fix by generating a PThread.currentProxiedOperationCallerThread check in handleAsyncFunction (jsifier.mjs): when in a proxied context, call the inner function directly and skip the Asyncify unwind, letting the proxy mechanism handle the async return.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When in a proxied context, skip the Asyncify unwind and call
startAsync()directly, letting the proxy mechanism handle theasync return.
This already affects
__syscall_polland would also affect the new__syscall_ppoll.