question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@sentry/nextjs not reporting issues i serverless functions

See original GitHub issue

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

6.5.1

Description

I’ve recently started using the @sentry/nextjs package for a Nextjs site. I’ve followed through with the installation guide with one exception. I’m using environment variables instead of the file generated by the wizard. On the client side it works great, the releases and bugs are being tracked, but I’m getting no reports from my serveless functions when they throw errors.

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

const handler = async (req, res) => {
  throw new Error("API throw error test");
  res.status(200).json({ name: "John Doe" });
};

export default withSentry(handler);

This is the serverless function I am testing and nothing is showing up in my Sentry dashboard when it fails.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:28 (12 by maintainers)

github_iconTop GitHub Comments

20reactions
AbhiPrasadcommented, Jun 28, 2021

Hey everyone, thanks for all the comments and feedback.

We are currently working on a patch to fix these issues (and some of the linked issues) by changing how we do server side initialisation of the Sentry SDK - we hope to push something out ASAP.

4reactions
DavidChouinardcommented, Jun 24, 2021

For context: we had this issue when we first manually integrated Sentry with Vercel (before the Next.js plugin). The issue, as I remember, is that Sentry queues up exceptions to be sent to the server but Vercel terminates the function instantaneously — causing the exception to be lost.

Adding await Sentry.flush(2000) to the error path fixed the issue, the Next.js library should probably do that by default.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting for Next.js - Sentry Documentation
If your application started to misbehave because of performing additional OPTIONS requests, it is most likely an issue with unwanted sentry-trace request ...
Read more >
Manual Setup for Next.js - DocBase AI Documentation
Learn how to set up the SDK manually.
Read more >
@sentry/node | Yarn - Package Manager
Official Sentry SDK for Node.js ... feat(nextjs): Check for Vercel Edge Function GA (#6565); feat(utils): Improved envelope parser (#6580); fix(nextjs): ...
Read more >
Sessions | Sentry Developer Documentation
Session updates must not change the attributes or data corrupts when ... crashed : a session should be reported as crashed under the...
Read more >
Using Next.js' middleware and Edge Functions - LogRocket Blog
Middleware is a Next.js feature that solves basic problems like authentication and geolocation with the help of Vercel Edge Functions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found