-
Notifications
You must be signed in to change notification settings - Fork 47
Description
I suggest adding additional sections to the README or FAQ:
Performance concerns with AsyncLocalStorage?
This question sometimes arises because of early concerns with async_hooks performance.
See for example: iamolegga/nestjs-pino#322
Is there currently a concern? (I am not aware of any.)
Stability of AsyncLocalStorage?
According to Node documentation, AsyncLocalStorage is stable, even though the parent async_hooks is still experimental.
https://nodejs.org/api/async_context.html#class-asynclocalstorage
Could a more performant request-scoped provider implementation solve this problem?
I wouldn't be so sure that using AsyncLocalStorage atm would be better (performance-wise) than properly designed request-scoped providers. - from nestjs/nest#1407 (comment)
In addition to performance, another problem with request-scoped providers is the scope hierarchy implementation in NestJS:
Scope bubbles up the injection chain. A controller that depends on a request-scoped provider will, itself, be request-scoped.
See https://stackoverflow.com/a/59681868/901597
This provider does not have this restriction.