Skip to content

Doesn't seem to work with serverless-http #83

Description

@JagCesar

Hey,

I'm using serverless-http on aws lambda with express. Everything works, but as soon as I try to add Serverless-sentry-plugin it breaks. Not sure if its any help, but this is the error I can see on cloud watch.

2025-02-16T17:26:19.573Z	undefined	ERROR	Uncaught Exception 	
{
    "errorType": "TypeError",
    "errorMessage": "Cannot read properties of undefined (reading 'OnUncaughtException')",
    "stack": [
        "TypeError: Cannot read properties of undefined (reading 'OnUncaughtException')",
        "    at /var/task/node_modules/serverless-sentry-lib/dist/index.js:143:106",
        "    at Array.filter (<anonymous>)",
        "    at integrations (/var/task/node_modules/serverless-sentry-lib/dist/index.js:142:33)",
        "    at Module.getIntegrationsToSetup (/var/task/node_modules/@sentry/core/build/cjs/integration.js:52:38)",
        "    at getClientOptions (/var/task/node_modules/@sentry/node/build/cjs/sdk/index.js:221:24)",
        "    at _init (/var/task/node_modules/@sentry/node/build/cjs/sdk/index.js:90:19)",
        "    at Module.init (/var/task/node_modules/@sentry/node/build/cjs/sdk/index.js:73:10)",
        "    at initSentry (/var/task/node_modules/serverless-sentry-lib/dist/index.js:139:18)",
        "    at withSentry (/var/task/node_modules/serverless-sentry-lib/dist/index.js:296:163)",
        "    at Object.<anonymous> (/var/task/index.js:11:22)"
    ]
}

And this is my index.js

'use strict'

const withSentry = require("serverless-sentry-lib");
const serverless = require('serverless-http');

const app = require('./index/index')
module.exports.api = serverless(
    app,
    {
        binary: ['image/jpeg', 'image/png']
    }
);

The above works, but if I change it to:

module.exports.api = withSentry(
    serverless(
        app,
        {
            binary: ['image/jpeg', 'image/png']
        }
    )
);

It no longer works. Got any idea what it could be?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions