pouchdb / pouchdb-server

CouchDB-compatible server built on PouchDB and Node
Apache License 2.0
943 stars 155 forks source link

server responds very slowly when using cookie authentication #308

Open art-in opened 6 years ago

art-in commented 6 years ago

Server sometimes (like 80% chance) starts to respond very slowly (from 15 sec to infinity) when using cookie authentication.

It did not happen for me before I've started using (any) authentication.

  1. Start new pouchdb-server
  2. Add server admin (through Fauxton)
  3. Add new server user (through rest api)
  4. Create new database (api)
  5. Add user to database members (api)
  6. Receive session cookie for the user (api)
  7. Make several GET requests to database (api)

Actual: server responds very slowly, or does not respond at all. Only fix for this is to remove database and start from scratch.

When it happens, sometimes (like 10% chance) following error is thrown.

[pouchdb-server] (node:9252) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'instance_start_time' of undefined
    at d:\Projects\microcosm\microcosm\node_modules\pouchdb-server\node_modules\express-pouchdb\lib\routes\db.js:100:32
    at d:\Projects\microcosm\microcosm\node_modules\promise-nodify\index.js:22:7
    at <anonymous>

I'm using pouchdb-server for testing app auth in dev environment, and it is pain because of this.
Backing off to full couchdb for now.

pouchdb-server v2.3.7 - v4.0.0, adapter leveldb, win7

marten-de-vries commented 6 years ago

For that error to occur, db.info() needs to return undefined, which is weird. Is there anything special to your setup? (PouchDB plugins, a special leveldb backend, etc.?)

art-in commented 6 years ago

@marten-de-vries

Nothing special, pouchdb-server started without config file (only passing --host, --port, --dir, --n).

didair commented 6 years ago

I have also experienced this error from time to time, 4.0.0. This issue was created a while back, any solutions?

jareware commented 5 years ago

Also seeing this happen pretty consistently.

jareware commented 5 years ago

FWIW, I did notice that info() did complete correctly when I made the same request with curl, and my investigation lead me to notice that it wasn't exactly the same request; I was making the request without a username and password from the browser, and that was triggering the

TypeError: Cannot set property 'instance_start_time' of undefined

error in the info() handler.

I'm still not quite sure how that would make info() resolve with undefined, but oh well.

I'm not seeing the error anymore with a properly set Authorization header.