Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Explicitly capture getServerSideProps exceptions #1504

Closed

Conversation

masonmcelvain
Copy link
Contributor

@masonmcelvain masonmcelvain commented Mar 24, 2023

QA

Assuming #1492 hasn't been closed yet, visit the following url on a Vercel preview

/Parts/MacBook_Pro/Display_Components?p=-1%20OR%203%2B947-947-1%3D0%2B0%2B0%2B1

and verify that an error shows up in react-commerce-dev similar to this one.

Closes #1491

@vercel
Copy link

vercel bot commented Mar 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-commerce ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2023 9:02pm
react-commerce-prod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2023 9:02pm

@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2023

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 357.24 KB (🟡 +3.61 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

New Page Added

The following page was added to the bundle from the code in this PR:

Page Size (compressed) First Load
/myPage 290 B 357.52 KB

One Page Changed Size

The following page changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/_error 467 B (🟢 -196 B) 357.7 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Catches and reports `getServerSideProps` errors to sentry explicitly.

This is an attempt to workaround a potential bug in Sentry: getsentry/sentry-javascript#7602
@masonmcelvain
Copy link
Contributor Author

dev_block ✌🏻 on getting it to actually report the exception 😞

@danielbeardsley
Copy link
Member

I really would have expected the sentry plugin to register an unhandled rejection event handler:
https://nodejs.org/api/process.html#event-unhandledrejection

Maybe we need to? Or maybe we aren't activating the plugin correctly?

});
});
};
process.on('unhandledRejection', (reason) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't be doing this inside the withSentry() call. Otherwise, if you use withSentry() more than once it will subscribe multiple times. Vercel is kinda special in that they only run one next.js page per process, but not every environment is like that.

I think we should do it at the module level (sentry.client.config and sentry.server.config)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yea good call. This implementation didn't report to Sentry, nor did I see the logs, but I will try it in the config file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Womp womp still no dice when registered in sentry.server.config

In theory `withSentry` can be called more than once, but we only want to register one unhandled rejection listener per process. This registers the listener in the sentry server configuration, which is evaluated only once.
@dhmacs dhmacs deleted the explicitly-capture-serverside-props-exceptions branch April 12, 2023 12:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some errors are not reported to sentry
2 participants