Skip to content
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

Capturing exceptions with Sentry on the server doesn't work #289

Closed
tmcw opened this issue Jul 7, 2023 · 2 comments
Closed

Capturing exceptions with Sentry on the server doesn't work #289

tmcw opened this issue Jul 7, 2023 · 2 comments

Comments

@tmcw
Copy link

tmcw commented Jul 7, 2023

If you set up a fresh epic-stack instance and then apply this patch:

diff --git a/app/routes/_marketing+/index.tsx b/app/routes/_marketing+/index.tsx
index 2b2db56..52d4226 100644
--- a/app/routes/_marketing+/index.tsx
+++ b/app/routes/_marketing+/index.tsx
@@ -6,10 +6,12 @@ import {
 	TooltipProvider,
 	TooltipTrigger,
 } from '~/components/ui/tooltip.tsx'
+import * as Sentry from '@sentry/remix'
 
 export const meta: V2_MetaFunction = () => [{ title: 'Epic Notes' }]
 
 export default function Index() {
+	Sentry.captureException(new Error('test'))
 	return (
 		<main className="relative min-h-screen sm:flex sm:items-center sm:justify-center">
 			<div className="relative sm:pb-16 sm:pt-8">

Then you should be capturing an exception when you load the main page. Unfortunately, this doesn't work - you'll get an error:

TypeError: Sentry2.captureException is not a function
    at Index (file:///Users/tmcw/tmp/test-sentry/build/index.js?update=1688751527424:5162:18)
    at renderWithHooks (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:130591)
    at renderIndeterminateComponent (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:132952)
    at renderElement (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:139023)
    at renderNodeDestructiveImpl (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:141963)
    at renderNodeDestructive (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:141404)
    at renderIndeterminateComponent (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:134827)
    at renderElement (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:139023)
    at renderNodeDestructiveImpl (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:141963)
    at renderNodeDestructive (/Users/tmcw/tmp/test-sentry/node_modules/react-dom/cjs/react-dom-server.node.development.js:10:141404)

This is kind of a Sentry issue, but I've noticed that @AbhiPrasad is in this repo and I figure this is a perfect minimal testcase for this bug. Afaict, @sentry/remix is correctly resolved to the ESM version of that package, but it relies on @sentry/node and the resolution for @sentry/node is messed up, potentially importing the CJS version of that package and yielding a version of the Sentry object without any of its capturing methods.


On the other hand, though, this is reproducible in just Node and two lines, so I filed an even-more-minimal bug report at getsentry/sentry-javascript#8474 which might be better.

@scefali
Copy link
Contributor

scefali commented Jul 26, 2023

@kentcdodds should this be closed?

@kentcdodds
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants