Repository navigation
Make the sync argument an explicit __async option - #28093
Closed
guybedford wants to merge 2 commits into
Closed
guybedford wants to merge 2 commits into
guybedford wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for specifying __async options as an array (e.g., ['auto', 'sync'] or ['sync']) in JS libraries, allowing more granular control over when a function can return a Promise or must complete synchronously. It updates the documentation, jsifier, syscall library, module loading, and tests to support this new feature. Feedback on the changes suggests improving error handling in expandAsyncOptions to prevent cascading errors when an unknown async option is encountered.
Collaborator
Author
|
This is a little too messy - I think default on is the better alternative, and opt-in remains preferable to that. So sticking with the status quo. |
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.
This makes the
syncargument of #28022 an explicit opt-in, as an__asyncoptions list, in place of recognising it by the name of a body's last parameter.__asyncmay now be a list of options.'auto'is__async: 'auto'as before, and'sync'has the body told, in a trailingsyncparameter, whether it must complete synchronously:'auto'function no longer looks at its parameter names; listing'sync'is what provides the argument, and a listed'sync'whose last parameter is not namedsyncis a build error, as are an empty list and an unknown option.__sigis no longer consulted for this.['sync']alone is the function that blocks only when proxied from a pthread: it is never a suspending import, so underASYNCIFY/JSPIsyncistrue, andfalseonly on behalf of a sync-proxied pthread caller, which awaits a returned Promise. This is the contract offd_writewaiting on a full pipe (Blocking pipe writes from pthreads wait for the reader #28083), which must stay a plain import for everyprintfcaller; it requires__proxy: 'sync'.__async: trueand__async: 'auto'are unchanged.__syscall_polland__syscall_epoll_pwaitlist['auto', 'sync'].Tests:
jslib.test_jslib_async_auto_syncgains['sync']-only variants in plain,ASYNCIFYandPROXY_TO_PTHREADbuilds, andjslib.test_jslib_async_options_errorscovers the four build errors.Made with AI assistance under my review