-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
async_hooks: add trackPromises option to createHook() #61415
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
base: main
Are you sure you want to change the base?
Conversation
This adds a trackPromises option that allows users to completely opt out of the promise hooks that are installed whenever an async hook is added. For those who do not need to track promises, this avoids the excessive hook invocation and the heavy overhead from it. This option was previously already implemented internally to skip the noise from promise hooks when debugging async operations via the V8 inspector. This patch just exposes it.
f31931b to
2241850
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61415 +/- ##
========================================
Coverage 88.51% 88.52%
========================================
Files 704 704
Lines 208739 208897 +158
Branches 40274 40339 +65
========================================
+ Hits 184770 184917 +147
- Misses 15968 15969 +1
- Partials 8001 8011 +10
🚀 New features to boost your workflow:
|
| will not have the `before` and `after` callbacks fired on them. For more details | ||
| see the details of the V8 [PromiseHooks][] API. | ||
| ### Disabling promise execution tracking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW promise tracking might still be enabled because some other async_hooks instance is using it (e.g. domain, ALS in older node.js versions or if --no-async-context-frame is set).
not sure if it is worth to mention this somewhere here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an option and the default (tracking it by default) has not been changed - even when it is changed, the internal call sites can just specify it to be true explicitly, so I think it probably doesn't need documentation changes.
This adds a trackPromises option that allows users to completely opt out of the promise hooks that are installed whenever an async hook is added. For those who do not need to track promises, this avoids the excessive hook invocation and the heavy overhead from it.
This option was previously already implemented internally to skip the noise from promise hooks when debugging async operations via the V8 inspector. This patch just exposes it.
Refs: #57148