with-sentry-simple example doesn't work in server although it says it does.
See original GitHub issueThe readme.md
of the example states it works on the server-side.
This is a simple example showing how to use Sentry to catch & report errors on both client + server-side.
However, The example using @sentry/browser
which doesn’t work on the server (node environment)
Where can I simple alternative for using sentry on the server-side? the other example with-sentry
seems too complicated.
for some reason import @sentry/node
(latest version) in a simple nextjs project is met with an error
[ wait ] compiling ...
[ error ] ./node_modules/@sentry/node/esm/integrations/console.js
Module not found: Can't resolve 'console' in '/Users/lirancohen/Projects/amp-app/node_modules/@sentry/node/esm/integrations'
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Episode #108 - Tracking Errors with Sentry - YouTube
Sentry is an Open Source error tracking that helps developers monitor and fix crashes in real time. Learn how to add and configure...
Read more >Going to Production - Next.js
Before taking your Next.js application to production, here are some recommendations to ensure the best user experience.
Read more >Android Enterprise Docs@Work - Webdav can't use Custom Sentry ...
However, when I add new AppTunnel Rules for Docs@Work (Android Enterprise). ... when the community is here and can share working examples (with...
Read more >Debugging Production Issues With Sentry and Nuxt.js
The easiest way to use source maps is to deploy them on the server together with the application itself. This way, web browsers,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Some notes on how to get this working:
_app.js
is not client-side only, it it called on the server as well (you can verify this yourself with some console logs). Thus @shuhei-tagawa’s idea above to havenext.config.js
swap out@sentry/node
makes sense_document.js
is unnecessary._app.js
will run on the server andSentry.init
installs its own hooks forunhandledRejection
anduncaughtException
_error.js
. They are passed togetInitialProps({ err })
, except in the case of https://github.com/zeit/next.js/issues/8592. Thus, within_error.js
, you can useSentry.captureException
. Here are the cases I’ve found where Next.js will handle the errors:getInitialProps
on the servergetInitialProps
on the client (in hydration or navigation)const env = process.env; const v = env.VAR
will throw on the client, becauseprocess
does not exist)Note that
@sentry/browser
will still run in a Node environment, it just won’t hook itself in as well as@sentry/node
would.I’ll see if I can make a PR to the example if I get time. @leerob maybe we can collaborate. I want there to be a simple way to integrate Next.js with Sentry as well, that doesn’t involve a custom server.
For people looking to implement Sentry with Next.js, make sure to check out https://github.com/UnlyEd/next-right-now
Interesting parts are: