From 70c4045aa5ba169a8c730d92d377d1cf1d4710a6 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 23 Jun 2020 00:33:04 +0200 Subject: [PATCH] vm: add run-after-evaluate microtask mode This allows timeouts to apply to e.g. `Promise`s and `async function`s from code running inside of `vm.Context`s, by giving the Context its own microtasks queue. Fixes: https://github.com/nodejs/node/issues/3020 PR-URL: https://github.com/nodejs/node/pull/34023 Reviewed-By: James M Snell Reviewed-By: Denys Otrishko --- doc/api/vm.md | 74 ++++++++++++++--- lib/vm.js | 24 +++++- src/env.h | 1 + src/module_wrap.cc | 31 +++++--- src/module_wrap.h | 9 ++- src/node_contextify.cc | 79 +++++++++++++++++-- src/node_contextify.h | 28 +++++++ test/known_issues/known_issues.status | 3 - .../test-vm-timeout-escape-queuemicrotask.js | 2 +- .../test-vm-timeout-escape-promise-2.js | 38 +++++++++ ...test-vm-timeout-escape-promise-module-2.js | 42 ++++++++++ .../test-vm-timeout-escape-promise-module.js | 42 ++++++++++ .../test-vm-timeout-escape-promise.js | 8 +- 13 files changed, 342 insertions(+), 39 deletions(-) create mode 100644 test/parallel/test-vm-timeout-escape-promise-2.js create mode 100644 test/parallel/test-vm-timeout-escape-promise-module-2.js create mode 100644 test/parallel/test-vm-timeout-escape-promise-module.js rename test/{known_issues => parallel}/test-vm-timeout-escape-promise.js (74%) diff --git a/doc/api/vm.md b/doc/api/vm.md index 773173085cc7e6..6fd07b0fd910f0 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -188,6 +188,9 @@ overhead.