feathersjs-ecosystem / authentication

[MOVED] Feathers local, token, and OAuth authentication over REST and Websockets using JSON Web Tokens (JWT) with PassportJS.
MIT License
317 stars 118 forks source link

Unhandled Promise Rejection error. #489

Closed blopez2010 closed 7 years ago

blopez2010 commented 7 years ago

Hello,

I'm supporting a React Native app with a backend written in an older feathers and feathers authentication version. I can not upgrade it because it will cause a big impact on the backend and frontend software version and I can not do that because I could take days to make both products work as expected.

When I deliver the first app version I've been getting the following error:

unhandled_promise_rejection

The most weird thing is This only happens on first app login, later on it won't happen again

I've been circle around the app and there is no reason this error is being thrown, since I've commented all console.log commands on the code. Yesterday I read this post by @ekryski No auth token but the proposed fix could not be done since it is in a newer version.

What can I do in this case?

Thanks for any help

This is the backend package list: { "dependencies": { "aws-sdk": "^2.7.11", "bcrypt": "^1.0.2", "body-parser": "^1.15.2", "compression": "^1.6.2", "cors": "^2.8.1", "dauria": "^1.1.5", "feathers": "^2.0.2", "feathers-authentication": "^0.7.12", "feathers-blob": "^1.2.0", "feathers-configuration": "^0.3.3", "feathers-errors": "^2.5.0", "feathers-hooks": "^1.7.0", "feathers-rest": "^1.5.2", "feathers-rethinkdb": "^0.3.2", "feathers-sendgrid": "^0.2.1", "feathers-socketio": "^1.4.2", "feathers-stripe": "^0.3.0", "fs-blob-store": "^5.2.1", "hbs": "^4.0.1", "json2csv": "^3.7.3", "lodash": "^4.17.4", "md5": "^2.2.1", "multer": "^1.3.0", "passport": "^0.3.2", "rethinkdbdash": "^2.3.27", "s3-blob-store": "^1.2.3", "serve-favicon": "^2.3.2", "uws": "^0.14.1", "winston": "^2.3.0", "xlsx": "^0.8.7" }, "devDependencies": { "csv-parse": "^1.1.7", "feathers-socketio": "^1.4.2", "jshint": "^2.9.4", "lodash.concat": "^4.5.0", "lodash.map": "^4.6.0", "lodash.omit": "^4.5.0", "mocha": "^3.2.0", "node-fetch": "^1.6.3", "password-generator": "^2.0.6", "request": "^2.79.0", "socket.io": "^1.7.2", "yargs": "^6.5.0" } }

An this is the RN package list:

{ "dependencies": { "color": "^1.0.2", "feathers-authentication": "^0.7.12", "feathers-reactive": "^0.4.1", "lodash": "^4.17.2", "native-base": "0.5.20", "react": "~15.4.0-rc.4", "react-native": "0.38.0", "react-native-animated-steps": "^1.0.0", "react-native-code-push": "^1.16.0-beta", "react-native-cookies": "^2.0.0", "react-native-credit-card-input": "^0.3.1", "react-native-drawer": "^2.3.0", "react-native-elements": "^0.7.0", "react-native-fetch-blob": "^0.10.4", "react-native-gifted-messenger": "^0.1.4", "react-native-image-picker": "latest", "react-native-image-resizer": "0.0.12", "react-native-keyboard-spacer": "^0.3.0", "react-native-permissions": "^0.2.5", "react-native-router-flux": "^3.37.0", "react-native-share-actions": "^0.1.0", "react-native-vector-icons": "^3.0.0", "react-native-youtube": "^0.8.0", "rxjs": "^5.0.1", "socket.io-client": "1.6.0" }, "devDependencies": { "babel-cli": "^6.18.0", "babel-core": "^6.18.2", "babel-eslint": "^7.1.1", "babel-jest": "17.0.2", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-polyfill": "6.16.0", "babel-preset-react-native": "^1.9.1", "babel-preset-react-native-stage-0": "^1.0.1", "feathers": "^2.0.2", "feathers-authentication-client": "^0.1.6", "feathers-client": "^1.7.2", "feathers-hooks": "^1.6.1", "feathers-socketio": "^1.4.2", "immutable": "^3.8.1", "immutable-devtools": "^0.0.7", "jest": "17.0.3", "jest-react-native": "17.0.3", "proxyquire": "^1.7.10", "react-native-debugger-open": "^0.3.0", "react-native-mock": "^0.2.3", "react-redux": "^4.4.6", "react-test-renderer": "15.3.2", "redux": "^3.6.0", "redux-thunk": "^2.1.0", "remote-redux-devtools": "^0.4.1", "remote-redux-devtools-on-debugger": "^0.7.0" } }

Expected behavior

Install the app and don't see the error thrown.

Actual behavior

At first app installation, this error is being thrown having all console.log commands commented.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

NodeJS version: v6.9.4

Operating System: mac OS SIERRA v 10.12.4

React Native Version: react-native-cli: 2.0.1

blopez2010 commented 7 years ago

Actually, doing some tests, this error happens every time I started the app and doesn't have an token stored.

marshallswain commented 7 years ago

@blopez2010 It seems like all you would need to do is add a catch block after app.authenticate:

app.authenticate().catch(error => {console.log(error)})
blopez2010 commented 7 years ago

Awesome!! Thanks a lot @marshallswain it worked!!, I really didn't wanted to ask this as an issue but I didn't found the answer in the documentation either. Thanks a lot and have a good day!

marshallswain commented 7 years ago

Glad it worked. We don't have any aversion to answering questions in the GitHub issues. :wink: