-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CLIENT_FETCH_ERROR expected end of JSON input (next-auth + SST) #7797
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
Comments
So after further debugging I was able to see that the issue came specifically from here https://github.com/getsentry/sentry-javascript/blob/develop/packages/nextjs/src/config/webpack.ts#L166-L183. I think this was done in order to wrap api routes with some sentry magic and re-export to ensure this would provide the necessary debugging information in sentry but for some reason this was breaking my Luckily I found in the code that you guys have an option This caused me a long week of headache trying to figure out why my To reference a few for linking:
For those that do happen to come here my solution was to disable it on this specific route so my
I will leave this open for now to see what Sentry team will say about this but happy to close it as I don't think again auto instrumentation is required on this path. NextAuthJs also provides a logger option https://next-auth.js.org/configuration/options#logger that may be used to log errors / warnings that I think can be used to log outputs to Sentry, haven't tried or confirmed this yet. |
Hi, thanks for reporting this!
First of all, let's leave this open. Nobody should run into an issue like this and we would also still like to instrument the auth endpoint. As for the actual issue, I myself am using A few questions:
|
Hey, Yea fair enough, in hindsight if Sentry can auto instrument as much as reasonably possible that would be preferred. I thought it was weird I ran into it as well, but I did move to a new technology stack using AWS lambda with SST and while setting that up I then got this issue so not sure if it could be related.
Once I excluded the api path and the error stopped then I was able to login successfully in the app. |
Thanks for sharing your solution @hect1c. I also ran into this problem and don't think I could have figured out what was causing it on my own. Interestingly enough, I am also using SST to deploy my app. This makes me think that SST is a factor in what is causing this issue. Can confirm that adding |
While I do not know for sure yet, SST might be a contributing factor here. I have to check - sadly can't give a timeline right now. Any additional information as to what SST does or might do is useful for me to debug! |
Hmm I did consider the issue may be with SST but as I was able to isolate it to Sentry I didn't pursue further with SST. I am on their discord channel so may revisit this. @lforst You can find more info here https://sst.dev but essentially it's a framework that allows us to easily build and deploy our stacks to AWS Lambda and many other AWS services. In particular they have also open sourced a Nextjs builder called I think it would still be good to understand what Sentry is doing in particular and in the meantime I can check with the maintainers on the channel to understand what could potentially be causing this on that end and provide a link to the code so we can try and pinpoint this issue. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This issue caused me a lot of pain. Unfortunately this my 2nd lifetime trying to solve frustrating error that hurt crucial functionality... It would be appreciated if Sentry product team will consider this and add this to the docs. |
@yarinsa What exactly would you like to have added to the docs? Our docs are also open source so feel free to contribute any changes: https://github.com/getsentry/sentry-docs |
@lforst That there is a known issue with next auth ... |
Also bumping into this issue, wasted time till I found this ticket, please be sure to expose a bit better this kind of issue to at least avoid someone else having to waste time. |
@leog If you have concrete suggestions on what to document feel free to share your thoughts here or open a PR to our docs. We'll make sure it gets added. As it stands however, we are not aware of any conflicts with next-auth. I am using next-auth + Sentry in my personal project and I have no issues. If you have issues with SST + Sentry, I recommend opening an issue in their Repo. I have a hunch that they are doing some funky stuff that is incompatible. We are doing our best not to screw with anything. |
thank you @lforst for your input, I will try to find a good place to warn people about the usage of Sentry together with Open-Next and SST as it happened in my project. In the mean time I linked this issue to SST open-next project to follow up with them if there is anything to fix on their side. |
Just to add some more data to the issue, I have a deployment hosted on Vercel that is also experiencing this for a portion of users. Does not seem to be SST related. |
@joshsny thanks for the heads up! Just so that nobody is surprised, I will lock this issue for organizational purposes (No ill will intended! 😄). The "+1s" in this issue are not too helpful and this issue being kept open is incentivizing people to bandwagon. To have a meaningful investigation we would need a bit more detailed bug reports with reproduction examples. If you have issues similar to this one, please open a new issue and provide a minimal reproduction example. Feel free to reference this issue in your new issues. Thank you! |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g.
bundle.tracing.min.js
) in your SDK setup.@sentry/nextjs
SDK Version
7.47.0
Framework Version
Next 13.3.0
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
https://github.com/hect1c/nextjs-sentry-nextauth-lambda-error
I'm getting the
CLIENT_FETCH_ERROR unexpected end of JSON
input when loading the site. It's a bit odd as I was able to isolate the issue to my next.config.js. It appears it's related to my@sentry/nextjs
configuration. When I have the withSentryConfig set I get this error from next auth, but when I remove it no error and next-auth is happy. I've tried to debug next-auth to try and determine why it's giving me this error but to no avail. I definitely have everything set it up it should be fornext-auth
and mywithSentryConfig
is directly from the docs.I've tried different versions across next, next-auth and sentry but going back too far with my @sentry/nextjs config is just not an option.
Though the error is coming from
next-auth
I've decided to post here as I was hoping you would be able to point me in the right direction as to what may be causing this as I have not been able to figure it out aside from just removing withSentryConfig and settingmodule.exports = nextConfig
in the repro. I'm just not sure why a sentry config would affect next-auth in any way. I've also posted an issue atnext-auth
here: nextauthjs/next-auth#7200Expected Result
What should of happened is no error is displayed since I have the required environment variables and nextauth path setup correctly even with my
@sentry/nextjs
configurationActual Result
Site loads with this error from
next-auth
The text was updated successfully, but these errors were encountered: