Skip to content

@sentry/serverless "Cannot read properties of undefined (reading 'finish')" since 7.45.0 #7826

@TheHolyWaffle

Description

@TheHolyWaffle

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/serverless

SDK Version

7.45.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

       AWSLambda.init({
            dsn: env.get('SENTRY_DSN'),
            tracesSampleRate: 1.0,
            environment: env.get('ENVIRONMENT_NAME'),
            normalizeDepth: 0,
            release: env.get('SENTRY_RELEASE'),
            beforeSend(event, hint) {
                const originalException = hint.originalException;
                if (originalException instanceof CrmApiError && !originalException.sendToSentry) {
                    // Some exceptions are known errors than can occur during runtime.
                    // We don't want to pollute Sentry with these issues, these errors have 'sendToSentry' set to false
                    return null;
                }
                return event;
            },
            maxValueLength: 500, // default is 250, avoids cutting of Error's with a long 'message',
            integrations: [
                // Nodejs stacktraces by default point towards `/var/task/index.js`
                // We have to change this path so that it corresponds to the uploaded sourcemaps in Sentry. See .gitlab-ci.yml
                new RewriteFrames({
                    root: '/var/task',
                    prefix: `app:///${env.get('SENTRY_FUNCTION_ID')}/`,
                }),
            ],
        });

Steps to Reproduce

Wrap an AWS lambda handler using and throw an Error:

AWSLambda.wrapHandler(..., {
    captureAllSettledReasons: true,
})

Expected Result

Lambda does not fail

Actual Result

{
  "errorType": "TypeError",
  "errorMessage": "Cannot read properties of undefined (reading 'finish')",
  "trace": [
    "TypeError: Cannot read properties of undefined (reading 'finish')",
    "    at Runtime.handler (/var/task/index.js:28:35554)"
  ]
}

Metadata

Metadata

Assignees

Labels

Package: serverlessIssues related to the Sentry Serverless SDK
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions