gr2m / spawn-pouchdb-server

Configurable per-app pouchdb-server as a drop-in replacement for CouchDB
27 stars 13 forks source link

socket hangups #41

Closed cdaringe closed 8 years ago

cdaringe commented 8 years ago

hi all:

i periodically get socket hang up errors doing testing against spawn-pouchdb-server.

it's non-deterministic. i have a gut feeling that what's happening is my PouchDB changes() API has outbound HTTP requests that are still INFLIGHT when i cancel them and destroy my local pouch instance. consequently, because i've cancelled and destroyed my local db, i think "well, now's an OK time to teardown my server". However, if that INFLIGHT HTTP request is still being processed and i call stop which kills the server, I think i could reasonably assume a socket hang up error is caused as byproduct.

is there a way we can gracefully stop the server vs. killing it? not sure how that all plays out here.

let me know if that was too much too fast!

cdaringe commented 8 years ago

in fact, i added a setTimeout(() => server.stop(failOnErr), 100), and i can no longer produce the failure mode.

gr2m commented 8 years ago

@cdaringe thanks for the investigation, this is great! I personally don’t use spawn-pouchdb-server myself at this point, and I don’t want you to be blocked by this issue. I’d accept your workaround, could you send a PR? Maybe add a comment where your reference this issue? That'd be great

cdaringe commented 8 years ago

thanks @gr2m, i appreciate that! i think that my timeout hack in here might cause more grief than help. i'll hit-up the pouchdb fellas on pouchdb-server or express-pouchdb and see if they can perhaps add a SIGINT intercept or something and gracefully shutdown, and then from here we could just send that signal?

cdaringe commented 8 years ago

ps, what's the hoodie team doing if no longer pouch? you guys migrating to rethink? i may have to at somepoint, just to keep the network chatter down :(

gr2m commented 8 years ago

i'll hit-up the pouchdb fellas on pouchdb-server or express-pouchdb and see if they can perhaps add a SIGINT intercept or something and gracefully shutdown, and then from here we could just send that signal?

thanks <3

ps, what's the hoodie team doing if no longer pouch? you guys migrating to rethink? i may have to at somepoint, just to keep the network chatter down :(

The migration is done :) We just found a more elegant way than spawning an extra process for PouchDB Server in the background. Instead we use pouchdb directly to persist data and user accounts :)

The new Hoodie is ready, it uses PouchDB by default on the server, and it’s pretty damn cool: https://github.com/hoodiehq/hoodie#usage

gr2m commented 8 years ago

please not that I can no longer maintain this module, but am happy to give committer rights or hand it over entirely if you are interested. If you no longer use it, please close the issue :)

cdaringe commented 8 years ago

Still using it! Id be interested in pitching in :)

gr2m commented 8 years ago

@cdaringe I invited you as collaborator. Everything that gets merged to master will be automatically released using semantic-release. Avoid pushing changes to master directly, go through pull requests so others can follow. I’ll be watching the repo for a while and if it goes well, I’m happy to move it over to your account :)