Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Clark <daniec@microsoft.com>2021-02-10 00:23:39 +0300
committerDanielle Adams <adamzdanielle@gmail.com>2021-02-16 17:16:07 +0300
commitd96a97a2b9b14a4f5475129fbfe495588798f36a (patch)
tree31692062a06e74f1aeee20b9b8ce77fe57a64f44 /src
parent7d8fd3f5764ddf56c1e6788e66b7f25f1e76f767 (diff)
module: make synthetic module evaluation steps return a Promise to support top level await
Top level await expects that all module script evaluation returns a Promise. As such, update ModuleWrap::SyntheticModuleEvaluationStepsCallback to return a resolved Promise now that V8 has enabled top-level await by default. Unfortunately I don't have a spec reference that I can point to here because the Built-in modules proposal isn't yet updated for top level await. The corresponding change for Blink is https://chromium-review.googlesource.com/c/chromium/src/+/2568823. This will allow a workaround for Node in this V8 bugfix to be removed: https://chromium-review.googlesource.com/c/v8/v8/+/2673794. Fixes: https://github.com/nodejs/node/issues/37299 PR-URL: https://github.com/nodejs/node/pull/37300 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/module_wrap.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index 0ac36d4aa63..4885e65f9c5 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -665,7 +665,14 @@ MaybeLocal<Value> ModuleWrap::SyntheticModuleEvaluationStepsCallback(
try_catch.ReThrow();
return MaybeLocal<Value>();
}
- return Undefined(isolate);
+
+ Local<Promise::Resolver> resolver;
+ if (!Promise::Resolver::New(context).ToLocal(&resolver)) {
+ return MaybeLocal<Value>();
+ }
+
+ resolver->Resolve(context, Undefined(isolate)).ToChecked();
+ return resolver->GetPromise();
}
void ModuleWrap::SetSyntheticExport(const FunctionCallbackInfo<Value>& args) {