Repository navigation
Conversation
AsyncGeneratorWrapper.runDelegateFrame_ called .then() directly on the
value returned by the delegate's next/throw/return method. Async
iterators are allowed to return a plain {value, done} object, and
ECMA-262 Yield* awaits innerResult, so transpiled code rejected with
"...then is not a function" where native code works.
Wrap the result in Promise.resolve(), as the throw-without-throw
fallback below already does for delegate.return().
Fixes google#4385
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.
AsyncGeneratorWrapper.runDelegateFrame_calls.then()directly on whatever the delegate'snext,throworreturnreturns. An async iterator may return a plain{value, done}object, and ECMA-262Yield*awaitsinnerResult, so native code accepts it, but with--language_out ECMASCRIPT_2017or lower the outer generator rejects withthis.delegate_[a.method](...).then is not a function.Wrap the result in
Promise.resolve(), as the throw-without-throwfallback a few lines below already does fordelegate['return'](). Promises and thenables resolve as before, and a synchronous throw from the delegate still reaches the existingcatch.The runtime library's JS tests are not in the GitHub tree, so I tested end to end: built
//:compiler_uberjar_deploy.jarfrom master and from this branch, compiled a script that drivesyield*over plain-objectnext(),throw()andreturn()results (plus a thenable and an async generator as controls), and ran it in Node 22. On master all seven plain-object cases reject; with this change they all resolve, six of them exactly as native Node does, and the controls are unchanged. The seventh,return(v)duringyield*, now finishes withvinstead of the delegate's return value; master already does that with Promise-returning delegates, so I left it out of this change.bazelisk test //:allpasses (435 tests). If there is a place for a runtime test I can add one there.Fixes #4385