Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(async-rewriter2): fix interaction with domains MONGOSH-662 #751

Merged
merged 1 commit into from
Apr 1, 2021

Conversation

addaleax
Copy link
Contributor

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant