FreeFeed/freefeed-server

500 error after user registration

k0fi opened this issue · 3 comments

k0fi commented

Hi
On a fresh deployment on the server, I get 500 error when I try to register a user:

POST http://api.mysite.com/v1/users 500 (Internal Server Error)
In nginx erro. log I have:

2018/05/04 04:46:13 [error] 6718#6718: *3 no live upstreams while connecting to upstream, client: 1.2.3.4, server: api.mysite.com, request: "GET /socket.io/?EIO=3&transport =polling&t=MCgLATt HTTP/1.1", upstream: "http://localhost/socket.io/?EIO=3&transport=polli ng&t=MCgLATt", host: "api.mysite.com", referrer: "http://mysite.com/signup"

And yarns give me:

[2018/05/04 04:54:59.991] [ERROR] (node:7501) Warning: a promise was created in a handler at /srv/freefeed-server/node_modules/tarn/lib/Pool.js:310:24 but was not returned from it, see http://goo.gl/rRqMUw at new Promise (/srv/freefeed-server/node_modules/bluebird/js/release/promise.js:79:10)

And I can see tha the user is not inserted into users.

Appreciate your tips to resolve this.

try doing this:

  1. put debug(err); after this line https://github.com/FreeFeed/freefeed-server/blob/stable/app/support/exceptions.js#L19 (it should be the first line inside of if block)
  2. start server with additional env-var: DEBUG='*,-babel'. so it will be something like NODE_ENV=production DEBUG='*,-babel' yarn start

this should give you additional logging in terminal

k0fi commented

Here is the error that I get when I try to register user eee:

[2018/05/04 07:33:01.808] [ERROR] (node:10486) Warning: a promise was created in a handler at /srv/freefeed-server/node_modules/tarn/lib/Pool.js:310:24 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (/srv/freefeed-server/node_modules/bluebird/js/release/promise.js:79:10)
[2018/05/04 07:33:01.813] [ERROR] (node:10486) Warning: a promise was created in a handler at /srv/freefeed-server/node_modules/tarn/lib/Pool.js:280:14 but was not returned from it, see http://goo.gl/rRqMUw
    at new Promise (/srv/freefeed-server/node_modules/bluebird/js/release/promise.js:79:10)
  knex:client acquired connection from pool: __knexUid2 +47ms
  knex:client releasing connection to pool: __knexUid1 +0ms
  knex:query select count(*) from "users" where "username" = ? undefined +44ms
  knex:bindings [ 'eee' ] undefined +44ms
  freefeed:sql:error ERROR select count(*) from "users" where LOWER(email)=LOWER('test@me.com') +0ms
  freefeed:errors error: permission denied for relation users
  freefeed:errors     at Connection.parseE (/srv/freefeed-server/node_modules/pg/lib/connection.js:545:11)
  freefeed:errors     at Connection.parseMessage (/srv/freefeed-server/node_modules/pg/lib/connection.js:370:19)
  freefeed:errors     at Socket.<anonymous> (/srv/freefeed-server/node_modules/pg/lib/connection.js:113:22)
  freefeed:errors     at emitOne (events.js:116:13)
  freefeed:errors     at Socket.emit (events.js:211:7)
  freefeed:errors     at addChunk (_stream_readable.js:263:12)
  freefeed:errors     at readableAddChunk (_stream_readable.js:250:11)
  freefeed:errors     at Socket.Readable.push (_stream_readable.js:208:10)
  freefeed:errors     at TCP.onread (net.js:594:20)
  freefeed:errors From previous event:
  freefeed:errors     at Client_PG._query (/srv/freefeed-server/node_modules/knex/lib/dialects/postgres/index.js:287:12)
  freefeed:errors     at Client_PG.query (/srv/freefeed-server/node_modules/knex/lib/client.js:206:17)
  freefeed:errors     at Runner.<anonymous> (/srv/freefeed-server/node_modules/knex/lib/runner.js:155:36)
  freefeed:errors From previous event:
  freefeed:errors     at /srv/freefeed-server/node_modules/knex/lib/runner.js:61:21
  freefeed:errors From previous event:
  freefeed:errors     at Runner.run (/srv/freefeed-server/node_modules/knex/lib/runner.js:47:31)
  freefeed:errors     at Builder.Target.then (/srv/freefeed-server/node_modules/knex/lib/interface.js:39:43)
  freefeed:errors     at Object.existsUserEmail (/srv/freefeed-server/app/support/DbAdapter/users.js:60:32)
  freefeed:errors     at Function.<anonymous> (/srv/freefeed-server/app/models/user.js:223:36)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at Function.User.emailIsValid (/srv/freefeed-server/app/models/user.js:213:3)
  freefeed:errors     at User.isValidEmail (/srv/freefeed-server/app/models/user.js:210:17)
  freefeed:errors     at User.<anonymous> (/srv/freefeed-server/app/models/user.js:301:21)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at User.validate (/srv/freefeed-server/app/models/user.js:292:3)
  freefeed:errors     at User.<anonymous> (/srv/freefeed-server/app/models/user.js:320:12)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at User.validateOnCreate (/srv/freefeed-server/app/models/user.js:318:3)
  freefeed:errors     at User.<anonymous> (/srv/freefeed-server/app/models/user.js:332:16)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at User.create (/srv/freefeed-server/app/models/user.js:327:3)
  freefeed:errors     at /srv/freefeed-server/app/controllers/api/v1/UsersController.js:35:16
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at create (/srv/freefeed-server/app/controllers/api/v1/UsersController.js:18:28)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
  freefeed:errors     at /srv/freefeed-server/node_modules/koa-router/lib/router.js:346:16
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
  freefeed:errors     at /srv/freefeed-server/app/routes.js:61:11
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at findUser (/srv/freefeed-server/app/routes.js:41:9)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
  freefeed:errors     at /srv/freefeed-server/node_modules/koa-router/lib/router.js:346:16
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at /srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:36:12
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/lib/router.js:351:31)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at /srv/freefeed-server/app/routes.js:102:13
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at app.use (/srv/freefeed-server/app/routes.js:100:3)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at serve (/srv/freefeed-server/node_modules/koa-static/index.js:53:15)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at responseTime (/srv/freefeed-server/node_modules/koa-response-time/index.js:17:12)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at /srv/freefeed-server/config/environment.js:100:13
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at app.use (/srv/freefeed-server/config/environment.js:99:5)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at runCallback (timers.js:789:20)
  freefeed:errors     at tryOnImmediate (timers.js:751:5)
  freefeed:errors     at processImmediate [as _immediateCallback] (timers.js:722:5) +0ms
  freefeed:errors error: permission denied for relation users
  freefeed:errors     at Connection.parseE (/srv/freefeed-server/node_modules/pg/lib/connection.js:545:11)
  freefeed:errors     at Connection.parseMessage (/srv/freefeed-server/node_modules/pg/lib/connection.js:370:19)
  freefeed:errors     at Socket.<anonymous> (/srv/freefeed-server/node_modules/pg/lib/connection.js:113:22)
  freefeed:errors     at emitOne (events.js:116:13)
  freefeed:errors     at Socket.emit (events.js:211:7)
  freefeed:errors     at addChunk (_stream_readable.js:263:12)
  freefeed:errors     at readableAddChunk (_stream_readable.js:250:11)
  freefeed:errors     at Socket.Readable.push (_stream_readable.js:208:10)
  freefeed:errors     at TCP.onread (net.js:594:20)
  freefeed:errors From previous event:
  freefeed:errors     at Client_PG._query (/srv/freefeed-server/node_modules/knex/lib/dialects/postgres/index.js:287:12)
  freefeed:errors     at Client_PG.query (/srv/freefeed-server/node_modules/knex/lib/client.js:206:17)
  freefeed:errors     at Runner.<anonymous> (/srv/freefeed-server/node_modules/knex/lib/runner.js:155:36)
  freefeed:errors From previous event:
  freefeed:errors     at /srv/freefeed-server/node_modules/knex/lib/runner.js:61:21
  freefeed:errors From previous event:
  freefeed:errors     at Runner.run (/srv/freefeed-server/node_modules/knex/lib/runner.js:47:31)
  freefeed:errors     at Builder.Target.then (/srv/freefeed-server/node_modules/knex/lib/interface.js:39:43)
  freefeed:errors     at Object.existsUserEmail (/srv/freefeed-server/app/support/DbAdapter/users.js:60:32)
  freefeed:errors     at Function.<anonymous> (/srv/freefeed-server/app/models/user.js:223:36)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at Function.User.emailIsValid (/srv/freefeed-server/app/models/user.js:213:3)
  freefeed:errors     at User.isValidEmail (/srv/freefeed-server/app/models/user.js:210:17)
  freefeed:errors     at User.<anonymous> (/srv/freefeed-server/app/models/user.js:301:21)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at User.validate (/srv/freefeed-server/app/models/user.js:292:3)
  freefeed:errors     at User.<anonymous> (/srv/freefeed-server/app/models/user.js:320:12)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at User.validateOnCreate (/srv/freefeed-server/app/models/user.js:318:3)
  freefeed:errors     at User.<anonymous> (/srv/freefeed-server/app/models/user.js:332:16)
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at User.create (/srv/freefeed-server/app/models/user.js:327:3)
  freefeed:errors     at /srv/freefeed-server/app/controllers/api/v1/UsersController.js:35:16
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at create (/srv/freefeed-server/app/controllers/api/v1/UsersController.js:18:28)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
  freefeed:errors     at /srv/freefeed-server/node_modules/koa-router/lib/router.js:346:16
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
  freefeed:errors     at /srv/freefeed-server/app/routes.js:61:11
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at findUser (/srv/freefeed-server/app/routes.js:41:9)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
  freefeed:errors     at /srv/freefeed-server/node_modules/koa-router/lib/router.js:346:16
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
  freefeed:errors     at /srv/freefeed-server/node_modules/koa-router/node_modules/koa-compose/index.js:36:12
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-router/lib/router.js:351:31)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at /srv/freefeed-server/app/routes.js:102:13
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at app.use (/srv/freefeed-server/app/routes.js:100:3)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at serve (/srv/freefeed-server/node_modules/koa-static/index.js:53:15)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at responseTime (/srv/freefeed-server/node_modules/koa-response-time/index.js:17:12)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at /srv/freefeed-server/config/environment.js:100:13
  freefeed:errors     at Generator.next (<anonymous>)
  freefeed:errors     at app.use (/srv/freefeed-server/config/environment.js:99:5)
  freefeed:errors     at dispatch (/srv/freefeed-server/node_modules/koa-compose/index.js:42:32)
  freefeed:errors     at next (/srv/freefeed-server/node_modules/koa-compose/index.js:43:18)
  freefeed:errors     at runCallback (timers.js:789:20)
  freefeed:errors     at tryOnImmediate (timers.js:751:5)
  freefeed:errors     at processImmediate [as _immediateCallback] (timers.js:722:5) +0ms
  freefeed:request post/v1/users 100ms +0ms
  knex:client releasing connection to pool: __knexUid2 +11ms
  freefeed:sql:error ERROR select count(*) from "users" where "username" = 'eee' +9ms
  morgan log request +0ms
  engine:ws received "2" +25s
  engine:socket packet +25s
  engine:socket got ping +0ms
  engine:socket sending packet "pong" (undefined) +1ms
  engine:socket flushing buffer to transport +0ms
  engine:ws writing "3" +1ms
  engine:ws received "2" +25s
  engine:socket packet +25s
  engine:socket got ping +0ms
  engine:socket sending packet "pong" (undefined) +1ms
  engine:socket flushing buffer to transport +0ms
  engine:ws writing "3" +1ms
  engine:ws received "2" +25s
  engine:socket packet +25s
  engine:socket got ping +0ms
  engine:socket sending packet "pong" (undefined) +0ms
  engine:socket flushing buffer to transport +0ms

the critical row is error: permission denied for relation users

your db-user (the one in "production" section of knexfile.js) doesn't have sufficient access privileges to db