Skip to content

Issue with nestjs-stripe and Sentry integration #940

@fdegmecic

Description

@fdegmecic

After adding Sentry to my NestJS project, when there is an error inside a function annotated with @StripeWebhookHandler, there is this error:

at async StripeWebhookController.handleWebhook (/opt/render/project/src/node_modules/@golevelup/nestjs-stripe/lib/stripe.webhook.controller.js:35:9)
    at async StripeWebhookService.handleWebhook (/opt/render/project/src/node_modules/@golevelup/nestjs-stripe/lib/stripe.module.js:122:17)
    at async Promise.all (index 0)
    at Object.handler (/opt/render/project/src/node_modules/@nestjs/core/helpers/external-proxy.js:14:42)
    at ExternalExceptionsHandler.next (/opt/render/project/src/node_modules/@nestjs/core/exceptions/external-exceptions-handler.js:14:29)
    at ExternalExceptionsHandler.invokeCustomFilters (/opt/render/project/src/node_modules/@nestjs/core/exceptions/external-exceptions-handler.js:31:32)
    at SentryGlobalFilter.catch (/opt/render/project/src/node_modules/@sentry/nestjs/build/cjs/setup.js:65:25)
    at SentryGlobalFilter.catch (/opt/render/project/src/node_modules/@nestjs/core/exceptions/base-exception-filter.js:27:29)
    at ExpressAdapter.isHeadersSent (/opt/render/project/src/node_modules/@nestjs/platform-express/adapters/express-adapter.js:83:25)
TypeError: Cannot read properties of undefined (reading 'headersSent')

With this being the exact line causing the error:

    isHeadersSent(response) {
        return response.headersSent;
    }

I've tried googling but there isn't much to find, from digging into the exact location of the error, I can see that indeed, headersSent is null, but I am not sure how to set it, since the location of the controller is in golevelup/stripe.
https://github.com/golevelup/nestjs/blob/master/packages/stripe/src/stripe.webhook.controller.ts

Sentry version used: "@sentry/nestjs": "^8.30.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions