Skip to content

Support for AsyncLocalStorage from async_hooks #1170

@nabetti1720

Description

@nabetti1720

Although LLRT implements the async_hooks module, it does not expose AsyncLocalStorage.
https://nodejs.org/api/async_context.html#class-asynclocalstorage

It seems that several well-known packages have adopted or are considering adopting it, so if it is implemented in LLRT, I think it will be able to accommodate new use cases.

Some packages that already use it include:

Information on the packages we plan to adopt is as follows:
aws-powertools/powertools-lambda-typescript#2050 (comment)

Additionally, I'd encourage LLRT to add support for AsyncLocalStorage from async_hooks; even for Logger & Metrics (core utilities) we'll most likely start using this API in the next couple months to allow for future use cases.

There's even a new package called @aws/lambda-invoke-store (repo) that, quoting its readme "is designed to be integrated with the AWS Lambda Node.js Runtime Interface Client (RIC)", which means applications targeting versions of Node.js managed runtimes that use this package, might rely on AsyncLocalStorage and not work on LLRT.

Additionally, InvokeStore imported via @aws/lambda-invoke-store should be exposed as globalThis.awslambda.InvokeStore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions