Skip to content

Feature request: implement top-level await & ESM #1033

Closed
@dreamorosi

Description

@dreamorosi

Description of the feature request

Problem statement
With ES modules, developers may use top-level await within their functions. This allows developers to use the await keyword in the top level of the file. With this feature, Node.js functions may now complete asynchronous initialization code before handler invocations.

In the context of the Parameters utility, this minimises the execution time in favor of a longer and single initialisation time as parameters that are shared across invocations could be fetched ahead and used immediately when the handler is executed.

Summary of the feature
For this feature to be possible two things need to happen:

  • Feature request: build as esmodule #521 must be resolved and the all the harnesses to build in ESM must be available
  • e2e tests must be implemented
  • docs need to make it clear that top-level async/await can be used only with ESM

Code examples
N/A

Benefits for you and the wider AWS community
Shorter execution times, simpler handler logic

Describe alternatives you've considered
Fetching all secrets in the handler's scope.

Additional context
Depending on the strategy that is decided in #521 examples should be provided in the docs for both ESM and CJS since the latter won't have access to top-level async/await.

Related issues, RFCs

#846
#521

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityparametersThis item relates to the Parameters Utility

Type

No type

Projects

Status

Shipped

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions