-
-
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
"captureRemixServerException" is not exported by "node_modules/@sentry/remix/esm/index.client.js"
#9594
Comments
Hi @gustavopch thanks for writing in and thanks for investigating! If you follow the docs to set up Sentry in Remix (e.g. via the wizard), does this warning also occur? Furthermore, just to understand the impact - does this warning degrade functionality or is it just a warning? I'm not sure why our entry points ( Anyway, if this is how we can fix it we'll probably do it. Just wanna gather some more information before we apply this fix. |
@Lms24 Thanks for triaging the issue!
As I wrote in the original comment, I think this is only a warning and the app should be functional as long as it doesn't actually call
Sorry for extremely artificial repro..., but I think technically the same warning can be observed on https://stackblitz.com/edit/sveltejs-kit-template-default-d7udwt?file=src%2Fhooks.client.ts I think the condition to get this warning is to include the reference to "server only export names" in client build, which I don't think usually happens if user's server/client code is structured well. |
@hi-ogawa thanks a lot for jumping in! I see, this makes sense to me now.
I tend to agree and I'd like to avoid adding dummy functions if reasonably possible. I get that it's sometimes hard to distinguish if functions belong to the server or client part of a package but generally, users shouldn't call server code in client parts (and vice versa). @gustavopch any chance that this is the reason for the warning on your end? I'd like to understand your use case better to determine if there's action needed on our end. |
@Lms24 I have export const handleError = (error: unknown, { request }: DataFunctionArgs) => {
if (!request.signal.aborted) {
Log.e('💥 Error caught by handleError:', error, {
sentryMethod: 'captureRemixServerException',
request,
})
}
} So |
Thanks for providing more contexts. Btw, I just came across the idea of silencing certain rollup warning in a different context TanStack/query#5161 (comment) and I think this can be applied to this scenario as well: https://stackblitz.com/edit/remix-run-remix-2tt6qz?file=vite.config.ts import { unstable_vitePlugin as remix } from '@remix-run/dev';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
export default defineConfig({
plugins: [remix(), tsconfigPaths()],
build: {
rollupOptions: {
onwarn(message, defaultHandler) {
if (
message.code === 'MISSING_EXPORT' &&
message.binding === 'captureRemixServerException'
) {
// we can silence this warning by just return
console.log('++++++++++++');
console.log(message);
console.log('++++++++++++');
return;
}
defaultHandler(message);
},
},
},
}); I'm still unsure whether sentry side should have consistent exports or user code should workaround it only when necessary. |
Hey, thanks for the great discussion. I can see both points. We'll discuss internally to decide how we go about this. |
Workaround for Remix + Vite using https://github.com/pcattori/vite-env-only: serverOnly$(() => {
Sentry.captureRemixServerException(data, 'remix.server', options.request)
})!() The Vite plugin will remove the code inside |
It's been a while since the last update, what's the status? |
Hi @wouterds, no update so far on this. We're currently in the final stretch of releasing our new major version of the SDKs and all our time is spent there. My take (note, no final decision here): I'm still not convinced that we should add this due to the cost of increasing client bundle size but if folks really prefer the size hit over ensuring that there code runs where it should run, we can add it. Just need some time to get it in. PRs are welcome :) |
@onurtemizkan the changes from #12110 should address this right? |
@AbhiPrasad, no this is not addressed there, but I can open a PR if there is a consensus about exporting it from the client-side. |
Yes let's add a dummy implementation, with a debug log warning! |
Fix released with https://github.com/getsentry/sentry-javascript/releases/tag/8.10.0! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/remix
SDK Version
7.80.1
Framework Version
2.3.0
Link to Sentry event
No response
SDK Setup
Check the link to StackBlitz below.
Steps to Reproduce
npx vite build
to build the client bundle.Expected Result
The file
node_modules/@sentry/remix/esm/index.client.js
should probably export a dummycaptureRemixServerException
with an implementation likenew Error("Not implemented for client")
.Check this comment by Hiroshi on Remix's repo for more context: remix-run/remix#7973 (comment)
Actual Result
The text was updated successfully, but these errors were encountered: