Skip to content

Sentry import failing on AWS λ for v7 & v8.7.0 #12322

Closed
@SidPrak7

Description

@SidPrak7

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/aws-serverless

SDK Version

8.7.0

Framework Version

@sentry/aws-serverless

Link to Sentry event

No response

SDK Setup

import * as Sentry from '@sentry/aws-serverless';
        
Sentry.init({
  dsn: "SENTRY_DSN_HERE",

  // Add Performance Monitoring by setting tracesSampleRate and adding integration
  // Set tracesSampleRate to 1.0 to capture 100% of transactions
  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,
});

Steps to Reproduce

We tried the full combination set of these steps.

  1. Set up the λ layers
    We tried these two ARNs
  • arn:aws:lambda:us-west-2:943013980633:layer:SentryNodeServerlessSDK:247
  • arn:aws:lambda:us-west-2:943013980633:layer:SentryNodeServerlessSDKv7:1

We also manually built a layer and pushed it to the λ

  1. Set the env variables
    We tried these env vars
    SENTRY_DSN='SENTRY_DSN'
    SENTRY_TRACES_SAMPLE_RATE=1

These four variations of NODE_OPTIONS:
NODE_OPTIONS='-r @sentry/serverless/dist/awslambda-auto'
NODE_OPTIONS='-r @sentry/serverless/awslambda-auto'
NODE_OPTIONS='-r @sentry/aws-serverless/build/npm/cjs/awslambda-auto'
not setting NODE_OPTIONS

It might be relevant that our file is .mjs file.

We are only noting the relevant errors in the Actual Result section.

Expected Result

Sentry logs something.

Actual Result

For the v7 arn & node options with dist in it:

Cannot find package '@sentry/aws-serverless' imported from /var/task/index.mjs

For the v7 arn & node options without dist in it:

Error: Cannot find module '@sentry/serverless/awslambda-auto'

For the arn we got from the docs & node options with dist in it:

Error: Cannot find module '@sentry/serverless/dist/awslambda-auto'

For the arn we got from the docs & node options without dist in it:

Error: Cannot find module '@sentry/serverless/awslambda-auto'

For the arn we got from the docs & node options with cjs in it:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './build/npm/cjs/awslambda-auto' is not defined by "exports" in /opt/nodejs/node_modules/@sentry/aws-serverless/package.json

Also, since the official docs for loading the layer didn't specify setting NODE_OPTIONS, we also tried that:

Cannot find package '@sentry/aws-serverless' imported from /var/task/index.mjs\nDid you mean to import \"@sentry/aws-serverless/build/npm/cjs/index.js\"

Metadata

Metadata

Assignees

Labels

Package: aws-serverlessIssues related to the Sentry AWS Serverless SDK

Type

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions