-
-
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
Attempted import error: 'Replay' is not exported from '@sentry/nextjs' (imported as 'Sentry'). #9796
Comments
Hi @curiousercreative any chance that you're trying to import Replay into your server-side Sentry SDK setup ( |
@Lms24 yeah, that seems to be what's happening. I have an internal wrapper library around @sentry/nextjs that is being imported into the client, server, and edge config files. It exports three functions that reference private module data to reduce configuration duplication. So it's logging a compilation warning/error about the client config function despite it not being invoked in server-side code. |
I see, in this case, I'd argue that this is not a bug in our SDK. I understand that it's more convenient to have some configuration for both, client and server (or edge) in one place but this is beyond the SDK package's control. Going to close this issue in the meantime. Please let me know if you think it should be reopened, thank you! |
@Lms24 that's understandable. Only direction I'd ask to explore on Sentry's end is to export a stub that throws on invocation. So nextjs server and edge entry points would export Replay as a stub, but invocation would provide a clear error message that it's only available on the client. This should resolve the compilation error and yield better developer experience for others that are compiling or worse invoking outside of nextjs client. I'd be happy to submit a PR, but perhaps you've previously decided against this type of approach across the SDKs |
I understand your use case and it's been brought up before:
The problem here is that providing stubs is a little more complicated if we want to do it right. This wouldn't only involve shimming integrations but a lot of other functions that are only available on the browser or node side. Sure, If we provide stubs, I'd strongly argue that they shouldn't throw (our SDKs should never throw) but log a warning/error instead. We're still a bit undecided though if we wanna go down this road at all or not. Feel free to open a PR (I suggest we start small with NextJS and Replay/Browsertracing) but I can't guarantee that we will merge it in the end. If you still want to give it a try, we already have shims for Replay and Browsertracing, albeit for a slightly different purpose. Probably a good idea to reuse them if possible. |
Export common shims (BrowserTracing, Feedback, Replay) to improve DX by: - logging error when server/edge SDK inits invoke client only modules - avoiding compilation warnings for uninvoked client only configuration Fixes getsentryGH-9796
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
7.86.0
Framework Version
Next.js 14.0.4
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
pnpm build
Expected Result
no errors
Actual Result
The text was updated successfully, but these errors were encountered: