Skip to content
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

Always "Invalid state" in v1.2 #186

Closed
jstayton opened this issue Aug 28, 2019 · 28 comments · Fixed by #197
Closed

Always "Invalid state" in v1.2 #186

jstayton opened this issue Aug 28, 2019 · 28 comments · Fixed by #197

Comments

@jstayton
Copy link

Hey 👋

I just tried upgrading from v1.1.1 to v1.2 (doesn't matter which patch version), and I now get an "Invalid state" error 100% of the time when calling handleRedirectCallback. I've tried in both Chrome and Firefox, cleared cookies, etc. I didn't change any code – just the version number in package.json.

I'm happy to provide more details, I'm just not sure what would be helpful to know in this case. Let me know. Thanks!

@wdrobinson
Copy link

I'm seeing the same issue.

@luisrudge
Copy link
Contributor

I just ran our default react quick start (with an updated version of the SDK) and it worked.

image

Can you please try this to see if it works with you as well? https://auth0.com/docs/quickstart/spa/react/01-login?download=true

@Schmaga
Copy link

Schmaga commented Aug 29, 2019

I can confirm that we are having the same problem. Might it have something to do with being in a legacy tenant plan? We are using two tenants, one with a new free plan, one with a legacy plan. With the legacy plan, we are getting the error. The new tenant works. Just a thought. Have tried many other different things, none have helped, yet.

We have an angular 8 application, using an integration approach similar to your quickstart. Up until 1.1.1 we did not have any major issues.

I can also confirm that downgrading to 1.1.1 makes everything work again :)

@jstayton
Copy link
Author

@luisrudge The React quick start works for me as well with v1.2.2.

Here's how I'm creating the client, if it helps:

createAuth0Client({
  audience: 'http://localhost:3000',
  client_id: 'BmQe...',
  domain: '{my-development-domain}.auth0.com',
  redirect_uri: `${window.location.origin}/login/callback`
})

@Schmaga
Copy link

Schmaga commented Aug 29, 2019

Some more information: We are also getting Invalid State errors like this with version 1.1.1, but only with a few clients and not all the time, which is very weird:

Error: Invalid state
    at t.<anonymous> (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:333211)
    at https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:313979
    at Object.next (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:314084)
    at https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:313022
    at new M (https://web.my-app.app/polyfills-es2015.e9d02e561e557b4fb791.js:1:59695)
    at a (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:312799)
    at t.handleRedirectCallback (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:332791)
    at q.project (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:931852)
    at q._tryNext (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:575564)
    at q._next (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:575482)

The errors also sometimes come paired with the following, leading to a breakdown of the whole login-flow on some browsers and platforms, but working in others:

TypeError: Cannot read property 'split' of undefined
    at iss (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:329816)
    at t._verifyIdToken (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:330660)
    at t.<anonymous> (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:333444)
    at https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:313979
    at Object.next (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:314084)
    at c (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:312855)
    at s.invoke (https://web.my-app.app/polyfills-es2015.e9d02e561e557b4fb791.js:1:53113)
    at Object.onInvoke (https://web.my-app.app/main-es2015.2c76e8149da929396d9c.js:1:633354)
    at s.invoke (https://web.my-app.app/polyfills-es2015.e9d02e561e557b4fb791.js:1:53053)
    at i.run (https://web.my-app.app/polyfills-es2015.e9d02e561e557b4fb791.js:1:48622)

From the logs it seems that we have been having this problem since migrating to the new auth0-spa-js library. No entries like that before. I am not sure if this is related, but it certainly smells like a very very similar problem.

@luisrudge
Copy link
Contributor

luisrudge commented Aug 29, 2019

@Schmaga I tested the react quickstart with an old tenant and with a new one as well, both work 🤔 do you have any rules running in any of the tenants?

@Schmaga we had some conversations about the second error you're having: #70 (comment) - The first one is pretty weird though!

@jstayton @Schmaga Can you please send a HAR file of the failed attempt to luis.rudge@auth0.com? I'll take a look ASAP.

@wdrobinson
Copy link

@luisrudge it's happening to me with an angular 8 app. It works fine using a non prod build but as soon as the --prod flag is added to the build the invalid state bug appears.

@luisrudge
Copy link
Contributor

@wdrobinson perfect. Let me try that.

@luisrudge
Copy link
Contributor

@wdrobinson
I just tested this with our Angular QuickStart

  • download
  • open the root folder
  • npm install
  • npm run build
  • cd dist/login-demo
  • serve -s -p 3000 (this can be any local http server you are used to)

And this works as expected, no state errors. Can you please try that?

@wdrobinson
Copy link

@luisrudge just tested. Works fine using ng serve or ng build and fails with the error using ng serve --prod or ng build --prod.

@luisrudge
Copy link
Contributor

@wdrobinson perfect. I reproduced the issue. Thanks! @jstayton are you still using angular?

@jstayton
Copy link
Author

@luisrudge No, I'm using Vue.

@luisrudge
Copy link
Contributor

@jstayton can you build a quick repro that I can test it? I'm assuming it has to do with how the code is being minified/bundled, but I'm still investigating.

@jstayton
Copy link
Author

@luisrudge Yeah, I can try to throw something together. FWIW, I'm seeing this in development with Vue CLI, not just a production build like @wdrobinson found with Angular.

@kmaida
Copy link

kmaida commented Aug 29, 2019

I can reproduce this invalid state error in an Angular production build (ng build --prod) in the quick start using auth0-spa-js v1.2.2. If I roll back to v1.1.1 and then do a production build, the issue seems to go away.

@luisrudge
Copy link
Contributor

Ok folks, I found the issue. Not sure why, but vue-cli and ng-cli are aggressively trying to minify our already minified code, causing issues with one of our dependencies (qss).

image

Because of this bug, when our code tries to get the query string from the URL, it doesn't find the state param and fails. I'm already investigating a fix ASAP.

@jstayton
Copy link
Author

@luisrudge Great sleuthing! Thanks for your work on this.

@Enngage
Copy link

Enngage commented Aug 31, 2019

Just encountered this issue in prod builds of Angular 9. Awesome this is the works!

@luisrudge
Copy link
Contributor

Fixed in version 1.2.3

@adstep
Copy link

adstep commented Sep 3, 2019

Confirmed upgrading to 1.2.3 works for me!

@jstayton
Copy link
Author

jstayton commented Sep 3, 2019

@luisrudge Thanks for your work on this, but unfortunately, v1.2.3 didn't fix this for me. I've emailed you a HAR file with the details.

@Enngage
Copy link

Enngage commented Sep 3, 2019 via email

@stevehobbsdev
Copy link
Contributor

Yeah, I can try to throw something together. FWIW, I'm seeing this in development with Vue CLI, not just a production build like @wdrobinson found with Angular.

@jstayton It would be useful for us to see a repro from yourself to get to the bottom of this. We have a version of our Vue quickstart that has been upgraded to use the latest version of the SDK, and unfortunately I can't repro the issue there.

Could you perhaps try out this sample and compare the implementation with your own?

@wdrobinson
Copy link

Confirmed it's fixed for me as well!

@daviseford
Copy link

daviseford commented Oct 15, 2019

I am having this problem currently.

When users "Continue with Google", this fails silently in the background

Uncaught (in promise) Error: Invalid state
    at t.<anonymous> (auth0-spa-js.production.js:1712)

My app is set up using the React Quick Start instructions with no modifications to anything.

@luisrudge
Copy link
Contributor

@daviseford does it work if you use username/pass instead of google? are you using Auth0's development keys?

@daviseford
Copy link

Yes, and yes. I just created a ticket #245 for this if you want to move this conversation.

@luisrudge
Copy link
Contributor

Thanks! moving there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants