fix(async-rewriter2): fix interaction with domains MONGOSH-662 #751
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.
The fix I previously inserted for the “Node.js prints a warning
if we intentionally disregard a rejected Promise from the generated
inner async function” problem turned out to be problematic, because
it creates an infinite loop in the domain handler system.
This problem goes away with Node.js v14.15.2 (due to nodejs/node@0ad4f70),
but since we also support Node.js-v12.x environments
(and we would want to be resilient against changes to the
platform internals anyway), it makes sense to aim for a better
solution here.
This patch makes sure that the generated inner async function only
returns a meaningful value if its return value is actually used,
i.e. if we’re encountering an async-evaluation case where the
generated outer function actually just forwards the returned
Promise.