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

'Sign in' button in Authenticator UI triggers error message #139

Closed
mbahar opened this issue Jan 10, 2018 · 8 comments
Closed

'Sign in' button in Authenticator UI triggers error message #139

mbahar opened this issue Jan 10, 2018 · 8 comments

Comments

@mbahar
Copy link
Contributor

mbahar commented Jan 10, 2018

In React ;
Sign in action in Authenticator UI triggers following error message regardless of username/password: WEBPACK_IMPORTED_MODULE_0_aws_sdk_global.util.crypto.lib.randomBytes is not a function

I have used Mobile Hub generated aws-export.js with user Sign in enabled.

@mbahar mbahar changed the title React > 'Sign in' button in Authenticator UI triggers error message 'Sign in' button in Authenticator UI triggers error message Jan 10, 2018
@jsancho
Copy link

jsancho commented Jan 10, 2018

This could be a red-herring, but this exact same issue started happening to us only when making a production build* on the CI server with npm, i.e. npm run build

The project was scaffolded with create-react-app.

The resolution was to use yarn 1.3.2 and creating a build with yarn run build.
This was rather tricky to debug, as we could not reproduce the issue when running dev builds.

* a "production build" in create-react-app bundles and minifies all js code into a single file

@jonsmirl
Copy link

jonsmirl commented Jan 10, 2018

I can confirm this is a new bug.

I have both of the aws-sdk versions forced to match at 179. I still get the error.

I get this error in yellow box: ce.util.crypto.lib.randomBytes is not a function

@mbahar
Copy link
Contributor Author

mbahar commented Jan 10, 2018

@jsancho I still got the same error after doing the following (yarn 1.3.2 )

  1. rm -rf node_modules
  2. yarn run build
  3. serve -s build

Any suggestions here?

@jsancho
Copy link

jsancho commented Jan 10, 2018

@mbahar

Any suggestions here?
Maybe the fact that it worked for us with yarn instead of npm was a red herring indeed.

If I were to guess, I'd say that the new effort in reducing the dependencies has made something break during the bundling and minification process.

I'm new to React and webpack, so this is a bit beyond my level of skill at the minute.
If you are using create-react-app, you could always try to eject and turn off some of the steps that go into creating the production build. Somehow, try to find what is exactly happening to the internal dependencies to aws-sdk during the build process.

Alternatively, you could always revert back to amplify v0.1.30, which did not seem to have this problem...

@jonsmirl
Copy link

jonsmirl commented Jan 10, 2018

This seems to be fixed now. aws-sdk was broken. A new version has fixed it. Or maybe it was amazon-cognito-sdk that was broken.

Whatever it was, my app is working again.

@richardzcode
Copy link
Contributor

@mbahar are you still getting the error? I'm not able to reproduce in my "create-react-app" test app. If still happening, could you run npm list to get dependency tree? It most likely pretty big so could you save to a file npm list > dependencies.txt then maybe create a gist?

@mbahar
Copy link
Contributor Author

mbahar commented Jan 17, 2018

Fixed after the update.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants