Add checks for PROXY_SYNC_ASYNC#26209
Open
stephenduong1004 wants to merge 1 commit intoemscripten-core:mainfrom
Open
Add checks for PROXY_SYNC_ASYNC#26209stephenduong1004 wants to merge 1 commit intoemscripten-core:mainfrom
stephenduong1004 wants to merge 1 commit intoemscripten-core:mainfrom
Conversation
Check if the returned value is actually a Promise before attempting to use it as one. I got en error when using `fd_sync` without ASYNCIFY: https://github.com/emscripten-core/emscripten/blob/main/src/lib/libwasi.js#L556. It is assigned `__proxy: 'sync'` (https://github.com/emscripten-core/emscripten/blob/main/src/lib/libcore.js#L2627), making it being proxied using PROXY_SYNC_ASYNC mode while not being a Promise.
Collaborator
|
I think maybe we should instead mark the function as Also, we should add a test for this. Can you explain how you were able to reproduce? |
sbc100
added a commit
to sbc100/emscripten
that referenced
this pull request
Feb 3, 2026
This function is marked as `__async: 'auto'` which means it should return a promise when run in proxied mode on the main thread. However it wasn't always returning a promise. Adding the `async` keyword is the simplest way to ensure it always returns a promise. Also, update the `wrapSyscallFunction` function to preserve the async keyword. Replaces: emscripten-core#26209
sbc100
added a commit
to sbc100/emscripten
that referenced
this pull request
Feb 3, 2026
This function is marked as `__async: 'auto'` which means it should return a promise when run in proxied mode on the main thread. However it wasn't always returning a promise. Adding the `async` keyword is the simplest way to ensure it always returns a promise. Also, update the `wrapSyscallFunction` function to preserve the async keyword. Replaces: emscripten-core#26209
sbc100
added a commit
to sbc100/emscripten
that referenced
this pull request
Feb 3, 2026
This function is marked as `__async: 'auto'` which means it should return a promise when run in proxied mode on the main thread. However it wasn't always returning a promise. Adding the `async` keyword is the simplest way to ensure it always returns a promise. Also, update the `wrapSyscallFunction` function to preserve the async keyword. Replaces: emscripten-core#26209
sbc100
added a commit
to sbc100/emscripten
that referenced
this pull request
Feb 5, 2026
This function is marked as `__async: 'auto'` which means it should return a promise when run in proxied mode on the main thread. However it wasn't always returning a promise. Adding the `async` keyword is the simplest way to ensure it always returns a promise. Also, update the `wrapSyscallFunction` function to preserve the async keyword. Replaces: emscripten-core#26209
sbc100
added a commit
that referenced
this pull request
Feb 5, 2026
This function is marked as `__async: 'auto'` which means it should return a promise when run in proxied mode. Also, update the `wrapSyscallFunction` function to preserve the async keyword. This fix was needed when investigating using the `async` keyword instead. Even though it didn't end up working in this case its still a worthwhile fix. Replaces: #26209 --------- Co-authored-by: Alon Zakai <alonzakai@gmail.com>
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.
Check if the returned value is actually a Promise before attempting to use it as one.
I got en error when using
fd_syncwithout ASYNCIFY: https://github.com/emscripten-core/emscripten/blob/main/src/lib/libwasi.js#L556. It is assigned__proxy: 'sync'(https://github.com/emscripten-core/emscripten/blob/main/src/lib/libcore.js#L2627), making it being proxied using PROXY_SYNC_ASYNC mode while not being a Promise.