Skip to content

@sentry/nextjs not reporting errors from API (serverless) endpoints in Vercel #3917

Closed
@jmurty

Description

@jmurty

Package + Version

  • @sentry/nextjs

Version:

6.11.0

Description

I was unable to get error reporting from API endpoints deployed in Vercel (as serverless functions) with @sentry/nextjs version 6.11.0 but downgrading to 6.4.1 fixed in.

Our app is a new one built with Next.js 11.1 from create-next-app as of last week.

We used the latest @sentry/nextjs configured according to the documentation, and with additional changes following the with-sentry example: specifically, added _error.js page and err pass through to <Component/> in _app.js.

Before downgrading, client errors were logged fine but I couldn't get error reports from Vercel serverless functions at all.
Both client- and server-side errors were logged successfully to Sentry when running the project locally with yarn dev.

This is the failing API endpoint I used to test in file pages/api/boom.js:

import { withSentry } from "@sentry/nextjs";

const handler = async function handler(req, res) {
  // Trigger an exception
  boom();

  res.status(200).send("OK");
};

export default withSentry(handler);

The problem seems similar to other reported issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions