nestjs-steroids / async-context Goto Github PK
View Code? Open in Web Editor NEW:link: NestJS Async Context based on async_hooks
License: MIT License
:link: NestJS Async Context based on async_hooks
License: MIT License
Hello,
When I check de type file for AsyncContext, it looks like it:
export declare class AsyncContext implements OnModuleInit, OnModuleDestroy {
private readonly internalStorage;
private readonly asyncHookRef;
private static instance;
private constructor();
static getInstance(): AsyncContext;
onModuleInit(): void;
onModuleDestroy(): void;
set<TKey = any, TValue = any>(key: TKey, value: TValue): void;
get<TKey = any, TReturnValue = any>(key: TKey): TReturnValue;
register(): void;
private getAsyncStorage;
private static initialize;
}
It seems that we have some missing methods listed in the doc:
class AsyncContext {
// Clear all values from storage
clear(): void;
// Delete value by key from storage
delete(key: K): boolean;
// Iterate over storage
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
// Get value from storage by key
get(key: K): V | undefined;
// Check if key exists in storage
has(key: K): boolean;
// Set value by key in storage
set(key: K, value: V): this;
// Get number of keys that stored in storage
get size: number;
// Register context, it's better to use this method inside the interceptor
register(): void
// Register context for a callback, it's better to use this inside the middleware
registerCallback<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R
// Unregister context
unregister(): void
}
Regards
I have "[Nest] 2170 - 10/03/2021, 3:12:22 PM [ExceptionHandler] Async ID (8052) is not registered within internal cache."
error message during nest initialization.
What can be a reason?
If two users will send 2 requests simultaneously:
traceId: some-uuid-1
,traceId: some-uuid-2
,then:
some-uuid-2
(but it should log some-uuid-1
, becuase this is first request)some-uuid-2
Am I right or Am I wrong?
Examples: dto classes, util functions...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.