@opentelemetry/context-async-hooks
Advanced tools
| import { Context } from '@opentelemetry/api'; | ||
| import { AbstractAsyncHooksContextManager } from './AbstractAsyncHooksContextManager'; | ||
| /** | ||
| * @deprecated Use AsyncLocalStorageContextManager instead. | ||
| */ | ||
| export declare class AsyncHooksContextManager extends AbstractAsyncHooksContextManager { | ||
@@ -4,0 +7,0 @@ private _asyncHook; |
@@ -22,2 +22,5 @@ "use strict"; | ||
| const AbstractAsyncHooksContextManager_1 = require("./AbstractAsyncHooksContextManager"); | ||
| /** | ||
| * @deprecated Use AsyncLocalStorageContextManager instead. | ||
| */ | ||
| class AsyncHooksContextManager extends AbstractAsyncHooksContextManager_1.AbstractAsyncHooksContextManager { | ||
@@ -24,0 +27,0 @@ _asyncHook; |
@@ -1,2 +0,2 @@ | ||
| export declare const VERSION = "2.4.0"; | ||
| export declare const VERSION = "2.5.0"; | ||
| //# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
| // this is autogenerated file, see scripts/version-update.js | ||
| exports.VERSION = '2.4.0'; | ||
| exports.VERSION = '2.5.0'; | ||
| //# sourceMappingURL=version.js.map |
+4
-4
| { | ||
| "name": "@opentelemetry/context-async-hooks", | ||
| "version": "2.4.0", | ||
| "description": "OpenTelemetry AsyncHooks-based Context Manager", | ||
| "version": "2.5.0", | ||
| "description": "OpenTelemetry AsyncLocalStorage-based Context Manager", | ||
| "main": "build/src/index.js", | ||
@@ -48,3 +48,3 @@ "types": "build/src/index.d.ts", | ||
| "@types/mocha": "10.0.10", | ||
| "@types/node": "18.6.5", | ||
| "@types/node": "18.19.130", | ||
| "mocha": "11.7.5", | ||
@@ -59,3 +59,3 @@ "nyc": "17.1.0", | ||
| "sideEffects": false, | ||
| "gitHead": "5e6504d2a3a7ce3aaa211d9e2a5b002a0e4d7da1" | ||
| "gitHead": "38924cbff2a6e924ce8a2a227d3a72de52fbcd35" | ||
| } |
+1
-15
@@ -15,16 +15,4 @@ # OpenTelemetry async_hooks-based Context Managers | ||
| - `AsyncLocalStorageContextManager`, based on [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage) | ||
| - `AsyncHooksContextManager`, based on [`AsyncHook`](https://nodejs.org/api/async_hooks.html#async_hooks_class_asynchook) | ||
| - `AsyncHooksContextManager`, based on [`AsyncHook`](https://nodejs.org/api/async_hooks.html#async_hooks_class_asynchook). This is **deprecated** and will be removed in v3 (planned for mid-2025. `AsyncLocalStorage` is simpler, faster, available in Node.js v14.8.0 and later, and avoids [this possible DoS vulnerability](https://nodejs.org/en/blog/vulnerability/january-2026-dos-mitigation-async-hooks). | ||
| The former should be preferred over the latter as its implementation is substantially simpler than the latter's, and according to [Node.js docs](https://github.com/nodejs/node/blame/v17.1.0/doc/api/async_context.md#L42-L45), | ||
| > While you can create your own implementation [of `AsyncLocalStorage`] on top of [`AsyncHook`], `AsyncLocalStorage` should be preferred as it is a performant and memory safe implementation that involves significant optimizations that are non-obvious to implement. | ||
| `AsyncLocalStorage` is available in node `^12.17.0 || >= 13.10.0`, however `AsyncLocalStorageContextManager` is not enabled by default for node `<14.8.0` because of some important bugfixes which were introduced in `v14.8.0` (e.g., [nodejs/node#34573](https://github.com/nodejs/node/pull/34573)). | ||
| ## Limitations | ||
| It's possible that this package won't track context perfectly when used with certain packages. In particular, it inherits any bugs present in async_hooks. See [the known issues][pkgs-that-break-ah]. | ||
| async_hooks is still seeing significant correctness and performance fixes, it's recommended to run the latest Node.js LTS release to benefit from said fixes. | ||
| ## Prior art | ||
@@ -52,3 +40,2 @@ | ||
| [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat | ||
| [async-hooks-doc]: http://nodejs.org/dist/latest/docs/api/async_hooks.html | ||
| [def-context-manager]: https://opentelemetry.io/docs/instrumentation/js/api/context/#context-manager | ||
@@ -58,4 +45,3 @@ [dd-js-tracer-scope]: https://github.com/DataDog/dd-trace-js/blob/master/packages/dd-trace/src/scope.js | ||
| [diag-team-scope-discussion]: https://github.com/nodejs/diagnostics/issues/300 | ||
| [pkgs-that-break-ah]: https://github.com/nodejs/diagnostics/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Aasync-continuity | ||
| [npm-url]: https://www.npmjs.com/package/@opentelemetry/context-async-hooks | ||
| [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fcontext-async-hooks.svg |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
495
1.23%58090
-1.47%45
-23.73%