Skip to content

Bug: unable to use Lambda Layer with ESM bundles #2231

Closed
@dreamorosi

Description

@dreamorosi

Expected Behaviour

When attaching the v2 Lambda Layer with a Lambda function that uses ESM bundles the function should work normally.

Current Behaviour

When the conditions above are met, the function crashes at startup due to the fact that the code in the Lambda Layer containing an import using the require keyword in the Tracer provider.

The stack trace of the error suggests that the issue will happen even if a polyfill banner is used.

This seems to be due to the banner being included in the customer bundle while the layer code being evaluated/required before that.

Code snippet

N/A

Steps to Reproduce

N/A

Possible Solution

No response

Powertools for AWS Lambda (TypeScript) version

latest

AWS Lambda function runtime

20.x

Packaging format used

Lambda Layers

Execution logs

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedlayersItems related to the Lambda Layers pipeline

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions