-
-
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
TypeError: Cannot read properties of undefined (reading 'getElementById') #5667
Comments
Hey, thanks for writing in, Looks like this is being caused by
document is undefined, so document.getElementById('__NEXT_DATA__') is throwing an error. The funny thing is that this code should not be running in the server, but seems to be getting pulled in. We can tell this by looking at the stacktrace:
This might be related to the fact that you enabled |
Yeah. Error only with experimental-edge function |
We don't have the best support for Vercel's Edge Runtime as per: #5611 |
* chore(deps): update project dependencies * fix: add try/catch for GH api * ci: disable sentry on server * fix: fix server error with sentry getsentry/sentry-javascript#5667 * chore: add lint:fix
Looks like for some reason the import in @Shramkoweb, if this is a blocker for you, you might file an issue with them and see what they say. |
I had the same issue: The root cause is obviously #5611 – and I am not familiar with the internals of the Here is a temporary workaround for anyone else stuck. This will exclude the Sentry code in any edge functions. // next.config.js
const config = {
webpack: (config, options) => {
if (options.isServer && options.nextRuntime === 'edge') {
config.resolve.alias = {
...config.resolve.alias,
'./sentry.client.config.js': false,
'./sentry.server.config.js': false,
}
}
return config
}
}
module.exports = withSentryConfig(config) |
I'm having the same issue as well, as I'm using Vercel's OG Image generator. I've tried @wconnorwalsh's solution (modified), which didn't work for me, but my tech stack is different. Stack: Nx 15+, Next.js 13+, and deploying on Vercel. This did not work for me: const nextConfig = {
// ...
webpack: (config, options) => {
if (options.isServer && options.nextRuntime === 'edge') {
config.resolve.alias = {
...config.resolve.alias,
'./sentry.client.config.js': false,
'./sentry.server.config.js': false,
}
}
return config
}
// I've also tried this, which didn't work
sentry: {
autoInstrumentServerFunctions: false,
},
}
module.exports = withNx(withSentryConfig(nextConfig)) The only way I could get my build to work was to remove
I know sentry, doesn't "have the best support for Vercel's Edge Runtime" #5667 (comment), but there should be at least a way to ignore it for now. |
Ask and you shall receive, @l1qu1d. 🙂 It happens I just merged this today: #6207. I'm going to close this for now, but if y'all are still having issues once that PR is released (in 7.20), please let us know. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/nextjs
SDK Version
7.12.0
Framework Version
Link to Sentry event
No response
Steps to Reproduce
Expected Result
Zero errors
Actual Result
Link to CODE
The text was updated successfully, but these errors were encountered: