-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
vm: add run-after-evaluate microtask mode #34023
Conversation
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: nodejs#3020
@nodejs/vm |
Flushing microtasks seems like a good approach, but i'm not sure why that requires MicrotaskQueueWrap to exist or ModuleWrap to have a ContextifyContext instance. |
Mostly because of the comment in the class definition – there’s no real reason not to give the caller full flexibility over running the microtask queue, it’s just out of scope here.
It’s absolutely possible that I have missed a simpler way to figure out the relevant microtask queue. If that is the case, please share it with me :) |
I'm having trouble thinking of actual use cases for this. You still can't use any stdlib functions from node (or native addons) even if they use microtasks instead of node ticks. afaict anytime you would want to use this option, you should probably be using |
Fwiw, multi-context support for Node.js is not totally unthinkable at this point anymore. Quite a few of our internal bindings are set up in a way that would support that by now.
I mean, if you go that route, you might as well say that anybody who wants to use the |
This comment has been minimized.
This comment has been minimized.
Landed in f63436d |
Notable changes: doc: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 PR-URL: TODO
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 * (SEMVER-MINOR) update V8 to 8.4.371.19 (Michaël Zasso) [#33579](#33579) module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 * (SEMVER-MINOR) update V8 to 8.4.371.19 (Michaël Zasso) [#33579](#33579) module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 * (SEMVER-MINOR) update V8 to 8.4.371.19 (Michaël Zasso) [#33579](#33579) module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 * (SEMVER-MINOR) update V8 to 8.4.371.19 (Michaël Zasso) [#33579](#33579) module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 * (SEMVER-MINOR) update V8 to 8.4.371.19 (Michaël Zasso) [#33579](#33579) module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 * (SEMVER-MINOR) update V8 to 8.4.371.19 (Michaël Zasso) [#33579](#33579) module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
Notable changes: deps: * upgrade npm to 6.14.6 (claudiahdz) #34246 * upgrade to libuv 1.38.1 (Colin Ihrig) #34187 * (SEMVER-MINOR) update V8 to 8.4.371.19 (Michaël Zasso) [#33579](#33579) module: * (SEMVER-MINOR) deprecate module.parent (Antoine du HAMEL) #32217 * (SEMVER-MINOR) package "imports" field (Guy Bedford) #34117 src: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 * (SEMVER-MINOR) allow embedders to disable esm loader (Shelley Vohr) #34060 tls: * (SEMVER-MINOR) make 'createSecureContext' honor more options (Mateusz Krawczuk) #33974 vm: * (SEMVER-MINOR) add run-after-evaluate microtask mode (Anna Henningsen) #34023 worker: * (SEMVER-MINOR) add option to track unmanaged file descriptors (Anna Henningsen) #34303 New Collaborators: * add danielleadams to collaborators (Danielle Adams) #34360 * add sxa as collaborator (Stewart X Addison) #34338 * add ruyadorno to collaborators (Ruy Adorno) #34297 PR-URL: #34371
This allows timeouts to apply to e.g.
Promise
s andasync function
sfrom code running inside of
vm.Context
s, by giving the Context itsown microtasks queue.
Fixes: #3020
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes