Skip to content

handleUpdateToRevocableSession cause HTTP 500 error #2720

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

Closed
mmarshak opened this issue Sep 17, 2016 · 13 comments
Closed

handleUpdateToRevocableSession cause HTTP 500 error #2720

mmarshak opened this issue Sep 17, 2016 · 13 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@mmarshak
Copy link

Issue Description

I am using Parse server 2.2.19, and Parse client SDK 1.14.2 on iOS app.
Parse server is hosted on AWS using Elastic Beanstalk, where I have NGINX as load balancer, and Parse server running on EC2. The mongoDB is hosted in mLab.

I had an iOS app that connected to api.parse.com that did not used revokable session.
We released a new version of the app that is now connected to Parse Served, and we call from the app the following code -

[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id configuration) {
configuration.applicationId = @"XXXXXX";
configuration.clientKey = @"YYYY";

configuration.server = @"ZZZZ ";

configuration.localDatastoreEnabled = YES ;

}]];

[PFUser enableRevocableSessionInBackground];

Now I get every few minutes the following warning from AWS with the following-

Message: Environment health has transitioned from Ok to Warning. 100.0 % of the requests are failing with HTTP 5xx.

Steps to reproduce

Call [PFUser enableRevocableSessionInBackground].

Expected Results

Calling enableRevocableSessionInBackground should not generate any 500 errors.

Actual Outcome

Calling enableRevocableSessionInBackground should generate any 500 errors.

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 2.2.19
    • Operating System: ubuntu
    • Hardware: NGINX , EC2
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): AWS
  • Database
    • MongoDB version: 3.0.x
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

Logs/Trace

/var/log/nginx/access.log

172.31.57.70 - - [17/Sep/2016:13:30:54 +0000] "PUT /server/classes/_Installation/cVDvKNxn7j HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "107.77.223.68"
172.31.57.70 - - [17/Sep/2016:13:32:25 +0000] "PUT /server/classes/_Installation/O0gdCix8pw HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/808.0.2 Darwin/16.0.0" "108.7.56.162"
172.31.18.53 - - [17/Sep/2016:13:32:28 +0000] "PUT /server/classes/_Installation/pegHJd1ULm HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/808.0.2 Darwin/16.0.0" "64.30.72.169"
172.31.18.53 - - [17/Sep/2016:13:32:39 +0000] "PUT /server/classes/_Installation/h58cNPGdqL HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/808.0.2 Darwin/16.0.0" "107.77.226.213"
172.31.57.70 - - [17/Sep/2016:13:32:40 +0000] "PUT /server/classes/_Installation/WtscPBtEM2 HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "75.68.90.83"
172.31.18.53 - - [17/Sep/2016:13:32:42 +0000] "PUT /server/classes/_Installation/5vs215XGgF HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "174.192.24.110"
172.31.57.70 - - [17/Sep/2016:13:33:07 +0000] "PUT /server/classes/_Installation/j2fvZhFU5K HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/808.0.2 Darwin/16.0.0" "74.104.123.65"
172.31.57.70 - - [17/Sep/2016:13:33:21 +0000] "POST /server/classes/SessionViewing HTTP/1.1" 201 64 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "71.232.78.165"
172.31.57.70 - - [17/Sep/2016:13:33:21 +0000] "PUT /server/classes/_Installation/pktZIdC2Jv HTTP/1.1" 200 86 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "71.232.78.165"
172.31.57.70 - - [17/Sep/2016:13:33:22 +0000] "PUT /server/classes/_Installation/pktZIdC2Jv HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "71.232.78.165"
172.31.18.53 - - [17/Sep/2016:13:33:53 +0000] "PUT /server/classes/_Installation/IEn1vQQg3e HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/808.0.2 Darwin/16.0.0" "174.192.29.227"
172.31.57.70 - - [17/Sep/2016:13:34:10 +0000] "POST /server/upgradeToRevocableSession HTTP/1.1" 500 45 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "66.87.124.62"
172.31.57.70 - - [17/Sep/2016:13:34:10 +0000] "GET /server/config HTTP/1.1" 200 2821 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "66.87.124.62"
172.31.57.70 - - [17/Sep/2016:13:34:12 +0000] "PUT /server/classes/_Installation/yUNydcAcTu HTTP/1.1" 200 71 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "66.87.124.62"
172.31.18.53 - - [17/Sep/2016:13:34:43 +0000] "POST /server/events/AppOpened HTTP/1.1" 200 2 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "108.26.217.154"
172.31.18.53 - - [17/Sep/2016:13:34:43 +0000] "GET /server/config HTTP/1.1" 200 2821 "-" "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0" "108.26.217.154"

/var/log/nodejs/nodejs.log

�[31merror�[39m: Error handling request: [TypeError: Cannot read property 'id' of undefined]
�[31merror�[39m: Uncaught internal server error. [TypeError: Cannot read property 'id' of undefined] TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
�[31merror�[39m: Error handling request: [TypeError: Cannot read property 'id' of undefined]
�[31merror�[39m: Uncaught internal server error. [TypeError: Cannot read property 'id' of undefined] TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
�[31merror�[39m: Error handling request: [TypeError: Cannot read property 'id' of undefined]
�[31merror�[39m: Uncaught internal server error. [TypeError: Cannot read property 'id' of undefined] TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
�[31merror�[39m: Error handling request: [TypeError: Cannot read property 'id' of undefined]
�[31merror�[39m: Uncaught internal server error. [TypeError: Cannot read property 'id' of undefined] TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)
TypeError: Cannot read property 'id' of undefined
at SessionsRouter.handleUpdateToRevocableSession (/var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)
at /var/app/current/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:259:9
at /var/app/current/node_modules/parse-server/lib/PromiseRouter.js:295:9
at Layer.handle as handle_request
at next (/var/app/current/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/var/app/current/node_modules/express/lib/router/route.js:112:3)
at Layer.handle as handle_request
at /var/app/current/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/var/app/current/node_modules/express/lib/router/index.js:330:12)

@flovilmart
Copy link
Contributor

Thanks for reporting it, can you run with VERBOSE=1 so we can see what type of request is yielding that error?

the auth.user should not be undefined as the case should be handled here:

https://github.com/ParsePlatform/parse-server/blob/master/src/Auth.js#L89

@flovilmart flovilmart added type:bug Impaired feature or lacking behavior that is likely assumed troubleshooting labels Sep 17, 2016
@mmarshak
Copy link
Author

Sure, I just run Parse server on my local host and I get the same issue with VERBOSE, see the log bellow.

To recreate the issue I run my app with Anonymous connected to api.parse.com with commenting out the call for [PFUser enableRevocableSessionInBackground];

The I modified the app to point to my local Parse server and uncommenting the call - [PFUser enableRevocableSessionInBackground];

And I get the same error as we see with AWS.

{
"level": "verbose",
"message": "Support key pairs Map {}",
"timestamp": "2016-09-17T15:34:42.797Z"
}
{
"level": "info",
"message": "Parse LiveQuery Server starts running",
"timestamp": "2016-09-17T15:34:42.828Z"
}
{
"method": "POST",
"url": "/pserver/upgradeToRevocableSession",
"headers": {
"host": "0daf129a.ngrok.io",
"user-agent": "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0",
"x-parse-app-display-version": "1.7.0",
"accept": "/",
"x-parse-application-id": "XXXXXXXXXXXXXXX",
"accept-language": "en-us",
"x-parse-client-key": "YYYYYYYYYYYYYYYYY",
"x-parse-os-version": "9.3.5 (13G36)",
"x-parse-app-build-version": "510",
"x-parse-client-version": "i1.14.2",
"x-parse-installation-id": "96e7029b-fa6c-48f6-928b-11165ce3e609",
"content-length": "0",
"accept-encoding": "gzip, deflate",
"x-forwarded-for": "108.26.217.154"
},
"body": {},
"level": "verbose",
"message": "REQUEST for [POST] /pserver/upgradeToRevocableSession: {}",
"timestamp": "2016-09-17T15:36:02.505Z"
}
{
"error": {},
"level": "error",
"message": "Error handling request: [TypeError: Cannot read property 'id' of undefined]",
"timestamp": "2016-09-17T15:36:02.506Z"
}
{
"level": "error",
"message": "Uncaught internal server error. [TypeError: Cannot read property 'id' of undefined] TypeError: Cannot read property 'id' of undefined\n at SessionsRouter.handleUpdateToRevocableSession (/Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/parse-server/lib/Routers/SessionsRouter.js:109:25)\n at /Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/parse-server/lib/Routers/SessionsRouter.js:154:23\n at /Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/parse-server/lib/PromiseRouter.js:259:9\n at /Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/parse-server/lib/PromiseRouter.js:295:9\n at Layer.handle as handle_request\n at next (/Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/express/lib/router/route.js:131:13)\n at Route.dispatch (/Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/express/lib/router/route.js:112:3)\n at Layer.handle as handle_request\n at /Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/express/lib/router/index.js:277:22\n at Function.process_params (/Users/mmarshak/Projects/GoPapaya-Parse-Server/node_modules/express/lib/router/index.js:330:12)",
"timestamp": "2016-09-17T15:36:02.508Z"
}
{
"method": "POST",
"url": "/pserver/events/AppOpened",
"headers": {
"host": "0daf129a.ngrok.io",
"x-parse-app-display-version": "1.7.0",
"x-parse-application-id": "XXXXXXXXXXXXXXX",
"accept": "/",
"accept-language": "en-us",
"x-parse-os-version": "9.3.5 (13G36)",
"x-parse-client-key": "YYYYYYYYYYYYYYYYY",
"user-agent": "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0",
"x-parse-app-build-version": "510",
"content-type": "application/json; charset=utf-8",
"x-parse-client-version": "i1.14.2",
"x-parse-installation-id": "96e7029b-fa6c-48f6-928b-11165ce3e609",
"content-length": "57",
"accept-encoding": "gzip, deflate",
"x-forwarded-for": "108.26.217.154"
},
"body": {
"at": {
"iso": "2016-09-17T15:36:02.048Z",
"__type": "Date"
}
},
"level": "verbose",
"message": "REQUEST for [POST] /pserver/events/AppOpened: {\n "at": {\n "iso": "2016-09-17T15:36:02.048Z",\n "__type": "Date"\n }\n}",
"timestamp": "2016-09-17T15:36:02.741Z"
}
{
"result": {
"response": {}
},
"level": "verbose",
"message": "RESPONSE from [POST] /pserver/events/AppOpened: {\n "response": {}\n}",
"timestamp": "2016-09-17T15:36:02.742Z"
}
{
"method": "POST",
"url": "/pserver/events/AppOpened",
"headers": {
"host": "0daf129a.ngrok.io",
"x-parse-app-display-version": "1.7.0",
"x-parse-application-id": "XXXXXXXXXXXXXXX",
"accept": "/",
"accept-language": "en-us",
"x-parse-os-version": "9.3.5 (13G36)",
"x-parse-client-key": "YYYYYYYYYYYYYYYYY",
"user-agent": "MyAppName/510 CFNetwork/758.5.3 Darwin/15.6.0",
"x-parse-app-build-version": "510",
"content-type": "application/json; charset=utf-8",
"x-parse-client-version": "i1.14.2",
"x-parse-installation-id": "96e7029b-fa6c-48f6-928b-11165ce3e609",
"content-length": "57",
"accept-encoding": "gzip, deflate",
"x-forwarded-for": "108.26.217.154"
},
"body": {
"at": {
"iso": "2016-09-17T15:36:02.812Z",
"__type": "Date"
}
},
"level": "verbose",
"message": "REQUEST for [POST] /pserver/events/AppOpened: {\n "at": {\n "iso": "2016-09-17T15:36:02.812Z",\n "__type": "Date"\n }\n}",
"timestamp": "2016-09-17T15:36:03.505Z"
}
{
"result": {
"response": {}
},
"level": "verbose",
"message": "RESPONSE from [POST] /pserver/events/AppOpened: {\n "response": {}\n}",
"timestamp": "2016-09-17T15:36:03.506Z"
}

@flovilmart
Copy link
Contributor

Interestingly, the sessionToken is not set but yet, it goes through with it. That's odd...

What's the response status from api.parse.com when calling that endpoint without a sessionToken?

@mmarshak
Copy link
Author

How can I see the response status from api.parse.com when calling that endpoint without a sessionToken?

@flovilmart
Copy link
Contributor

jUst run the same agains api.parse.com with https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/wiki/Network-Debug-Tool that will trace all requests/responses on your client

@flovilmart
Copy link
Contributor

Alright found it: {"code":101,"error":"invalid session"}

@flovilmart
Copy link
Contributor

working on a fix

@mmarshak
Copy link
Author

That is great.

Does this error has any side effect on the client app?

@flovilmart
Copy link
Contributor

it should not, as it's the same as what api.parse.com would return

@flovilmart
Copy link
Contributor

As with the current version without the fix, that should not have any side effects. I'll try to get something released soon on npm

@mmarshak
Copy link
Author

@flovilmart thank you again.

Do you have time estimate when your change will be released as part of 2.2.20?

I tried the follow experiment without your fix as follows

  1. Use old app connected to api.parse.com
  2. Upgrade to new version of the app with anonymous user and I get the error everything I launch the app, is this expected?
  3. I login with an existing user and relaunch and I do not get the error.
  4. I logout and relaunch the app and I getting the error again, is this expected to get the error also after logout?

@flovilmart
Copy link
Contributor

Yes this is expected, the error will occur any time the call to that endpoint is made and the sessionToken is not set (anonymous user not saved, or no user at all).

It's definitely gonna be part of 2.2.20, and I'm trying to setup a way so the master is easily usable thought the package.json without the npm link/submodules dance.

@mmarshak
Copy link
Author

Thank you for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

2 participants