pouchdb: Uncaught ETIMEDOUT exceptions

During a local Pouch DB (5.3.2) from remote DB (CouchDB 1.6.1) replication call, I am observing repeated exceptions - capture

The live replication call code is bare minimum -

localDB.replicate.from(remoteURL, { live: true, retry:true })

Is this expected? If so, could PochDB handle the long polling timeouts in a manner which doesn’t end up with uncaught exceptions?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 39 (24 by maintainers)

Commits related to this issue

Most upvoted comments

I was receiving the same error, but it is fixed now. The error cause: not canceling all PouchDB syncs on user logout. The error got resolved by canceling all syncs on user logout, like this:

const syncHandler=localDB.sync(remoteDB,{live:true, retry:true}).on('complete',res=>{
    console.log('Sync is canceled')
})

userDB.logout().then(res=>{
    syncHandler.cancel() // 'on-complete' is triggered
}).catch(err=>{
    console.log('err -> ', err)
})

Hi, i did it like theutopianster and it’s true, CouchDb is running well. Configuration: 1.6.1 on Windows, http Port 5984, https 6984 over Apache Webserver as Proxy. Used for GPS App. Tested with 5 cellphones simultan, no problem. Thanks a lot

Hey guys I had the same issue with running sync or replicate from puch enabled website to couch db. I finally figured out how to fix it, at least on my side. Basically the timeout parameter was the culprit because after I set the variable to 0 inside pouch js it worked. So in the file puchdb-6.1.2.js method api.allDocs I set opts.timeout = 0; and commented
('timeout' in opts) ? opts.timeout : ('timeout' in ajaxOpts) ? ajaxOpts.timeout : 30 * 1000; I tested with 30 min, 1 hour and more and it does not die anymore. I ran this with CouchDB 1.6.1 and 2.0 so I hope this works for you as well.

PS: I don’t see any heartbeat activity in Network trace so that may be the main issue. Does heartbeat work on your end?

@nolanlawson I upgraded the version to 6.0.7. But the error is still thrown. The error creeps in after a certain amount of time only.

Following is the error stack trace

raven.min.js:2 Error: ETIMEDOUT at XMLHttpRequest.xhr.onreadystatechange (http://localhost:8100/lib/pouchdb/dist/pouchdb.js:9613:15) at XMLHttpRequest.d (http://localhost:8100/lib/raven-js/dist/raven.min.js:2:4308) at timeoutReq (http://localhost:8100/lib/pouchdb/dist/pouchdb.js:9517:9) at d (http://localhost:8100/lib/raven-js/dist/raven.min.js:2:4308) undefineda.(anonymous function) @ raven.min.js:2(anonymous function) @ ionic.bundle.js:25642(anonymous function) @ ionic.bundle.js:22421(anonymous function) @ angular.min.js:2processQueue @ ionic.bundle.js:27887(anonymous function) @ ionic.bundle.js:27895$eval @ ionic.bundle.js:29158$digest @ ionic.bundle.js:28969(anonymous function) @ ionic.bundle.js:29197completeOutstandingRequest @ ionic.bundle.js:18706(anonymous function) @ ionic.bundle.js:18978d @ raven.min.js:2 raven.min.js:2 Paused in profile db sync Error: ETIMEDOUT at XMLHttpRequest.xhr.onreadystatechange (http://localhost:8100/lib/pouchdb/dist/pouchdb.js:9613:15) at XMLHttpRequest.d (http://localhost:8100/lib/raven-js/dist/raven.min.js:2:4308) at timeoutReq (http://localhost:8100/lib/pouchdb/dist/pouchdb.js:9517:9) at d (http://localhost:8100/lib/raven-js/dist/raven.min.js:2:4308)