-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Error: Invalid UTF-8 sequence crashing Vercel #67
Comments
This is happening to me as well on the production app. Need to degrade the version asap. |
@Nishchit14 which version did you downgrade? I continuously get this error in production too |
@k2xl |
@Nishchit14 @k2xl would you mind adding this option to all of your Supabase client-creation code, to see if it resolves the issue? Keep in mind that this will alter how the cookie is stored; so, if you are grabbing the cookie yourself, somewhere in your code, you'd need to change how that functions. I'm not offering this as a long-term solution, but rather a test. Although, if it's a client option then it could be used long-term. /* example only. this option is needed in all code that creates a client. */
export function createClient() {
return createBrowserClient(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookieEncoding: "raw"
}
)
} Roughly how long is the time between failures? |
Trying and will get back to you |
Still occurs. Happens an hour or so in |
I'm not sure what would be going on then. I went through every source file, and the only references I can find to base64url.js are when cookies are being encoded/decoded to/from base64 (or for tests). And you're sure you added that option in every place that a Supabase client is created? And the error is the same as the original? |
@j4w8n I added it to all the createClients that allow me to pass that cookieEncoding
|
@k2xl that's really strange. Can you verify the cookie is not being stored with a |
Actually the cookies still do begin with base64… |
@k2xl Is this reproducible during dev on your machine, or is it only during prod on Vercel? |
Reproduces on dev and on prod |
Ok... my bad, I wondered why the first part of the cookie was decodeable and others not, so I combined it 😄 (what a hacker I am) anyway, the string was also decodeable. I used this tool to decode: https://base64.guru/converter/decode and I had this warning: The character encoding was detected as “ISO-8859-1”, but the algorithm is inaccurate and there is a high probability that this is wrong. Because of this you can get the wrong results. To know for sure, please check the Character Encoding Detector tool. at the end of the json I had this
this might be the issue |
I "fixed" this for me, by deleting all the cookies and this issue never reappear, BUT i think I have an idea why it was present the first time, if you @Krovikan-Vamp could confirm one of this actions for you too, this will be the issue:
my idea is, if token was 4 cookies long, and is suddently 3 or the other way, it crashes, what makes totally sense IMHO. |
Hi @fincha, thanks for your insight! I notice the same thing that deleting all cookies resolves the issue; however only temporarily. This issue always comes back after the session times out (3600 seconds) and the user is on a page that checks I am not modifying the cookies/JWT via hooks or anything else. I also added the "cookieEncoding": "raw" prop, too. I already updated the codebase so I don't want to face any regressions by downgrading to Anyone else found a solution to this? If it applies I am authenticating through Azure but have not been able to resolve from that end. Thanks! 👾🚀 |
@Krovikan-Vamp did you get to a point where your first cookie doesn't start with |
I'm trying to reproduce this locally, with Google OAuth. Any secrets to getting the session large enough to be broken into three cookies? Right now it's only creating two for me. |
I was able to add some extra user data. |
@ptts I do find it interesting that your 2nd and 3rd cookies should've been able to be combined. Your 1st is of size 3216, and then 3013 and 154. That should've only required two cookies, since 3013 and 154 are a total of 3167 - well below the max of 3216. Right now, my first two cookies are 3216, then another of 1255. @k2xl @fincha @Nishchit14 @Krovikan-Vamp whenever you have issues, do you see this cookie size anomaly? |
Our users are facing this too - and it's pretty debilitating as it happens very often |
I did find a mechanism in the cookie-chunking logic, to where it's possible to have a "middle" cookie size of less than the typical 3216. After the whole value is encoded with All of that to say it's possible to have a couple of cookie sizes that could've been rolled into one cookie, but they were trying to do the above, so the content got split. If that makes sense. |
Bug report
Describe the bug
On version
Randomly been getting these errors for my app. Only solution is to destroy my cookies and refresh."@supabase/ssr": "^0.4.0",
Error: Invalid UTF-8 sequence
at (node_modules/@supabase/ssr/dist/module/utils/base64url.js:187:0)
at (node_modules/@supabase/ssr/dist/module/utils/base64url.js:90:0)
at (node_modules/@supabase/ssr/dist/module/cookies.js:246:30)
at (node_modules/@supabase/auth-js/dist/module/lib/helpers.js:100:0)
at (node_modules/@supabase/auth-js/dist/module/GoTrueClient.js:787:0)
at (node_modules/@supabase/auth-js/dist/module/GoTrueClient.js:768:0)
at (node_modules/@supabase/auth-js/dist/module/GoTrueClient.js:714:0)
This us a super weird bug where when I visit my website it just literally crashes. However clearing my cookies the website works for a bit then stops.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
I do not know how the bug occurs.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
Running on a nextjs app with supabase. My app allows google logins
The text was updated successfully, but these errors were encountered: