-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asynchronous errors aren't being reported in Next.js data-fetching methods on Vercel #7602
Comments
Catches and reports `getServerSideProps` errors to sentry explicitly. This is an attempt to workaround a potential bug in Sentry: getsentry/sentry-javascript#7602
Hi, you set |
I overlooked that config option, thank you for replying and pointing it out. I tested dropping I also tested using |
@masonmcelvain Hi, thanks for sharing your thoughts and experiments. I don't know if I can currently give a solution for this. It seems like Vercel is terminating the lambda before we're able to send the event out. |
My team and I haven't found a workaround either, but we'll share if we do.
That's my hunch too, thanks for your take on it. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Is it possible to tie the new |
@masonmcelvain Generally it is already using the new mechanism under the hood. I don't think this will resolve this issue though. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This is still happening, so I don't think it should be closed. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Bump |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
The issue here seems to be related to the lifecycle of Next.js 13. I managed to solve the problem by explicitly calling the
|
Looking at the original code above: export const getServerSideProps: GetServerSideProps = async (context) => {
if (context.query.myParam === 'two') {
// only throw conditionally so that this page actually builds
Promise.reject(new Error("We don't like page two!"));
}
return { props: {} };
}; I think the issue here is that you're not returning the promise created by The no-floating-promises ESLint rule is good for highlighting these. |
This was the only solution that worked for me. I have disabled the Sentry instrumentation and started to initialize it by myself. next.config.js // ...
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
const sentryOptions = {
// ...
// Disable the automatic instrumentation of API route handlers and server-side data fetching functions
autoInstrumentServerFunctions: false,
// ...
};
// ... API example // ...
/**
* API configuration for this endpoint.
*/
export const config = {
runtime: 'edge',
};
/**
* API endpoint.
*/
export default async function handler(req: NextRequest) {
try {
// ...
// Return success response
} catch (error) {
// Sentry.init...
// Sentry.withScope...
// ...
// Sentry.captureException...
// Return error response
}
} Thanks @AnasSafi. |
@timfish that's a great point, I agree that floating promises should be avoided. I confirmed that using If I remember correctly, I used a floating promise to demonstrate the failure method in a simple way. My original error is described in iFixit/react-commerce#1491 (specifically the following line). I think a promise was rejected in third party code from Algolia's Instantsearch library.
I don't want to wrap all usages of third party code in try/catch blocks, so I think this is still outstanding as long as the |
@masonmcelvain Yes, bugging the Next.js maintainers about a proper on-error hook would be amazing. Afaik they're looking into telemetry anyhow so this might even align with their objectives! |
Disclaimer: not specific to Vercel or What worked for me was:
|
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/nextjs
SDK Version
7.44.2
Framework Version
12.2.3
Link to Sentry event
https://ifixit.sentry.io/issues/4031066228/?project=6475315&query=is%3Aunresolved&referrer=issue-stream
SDK Setup
Our source is public here. Debugging branch here, on the latest Sentry version.
Steps to Reproduce
Similar to #6117 (which fixed this problem for synchronous errors), but reject a promise or throw an error in an async callback. When the project is run locally, the error is reported to Sentry. When deployed to Vercel, the error never appears in Sentry.
Expected Result
An error like this one gets reported to Sentry.
Actual Result
No error is reported to Sentry. Here are the Vercel logs, if it's helpful:
CC @lforst
The text was updated successfully, but these errors were encountered: