- During a replication, after PouchDB determines which docs should be pushed up and their contents, replicate's
writeDocsfunction is called which in turn calls tobulkDocsfunction. - When the target database is a CouchDB, the
bulkDocsfunction is aliased to thepouchdb-adapter-http's_bulkDocsfunction. _bulkDocsthen passes the request tofetchJSONfunction which then passes it toourFetch. Ifresponse.okis not truthy, an error is thrown here. Note the requirement that response body is valid JSON here. I'm assuming if a proxy returned a 200 status message but returned a body that just said something like "hello", this would throw an error and we would not have success.- The
ourFetchfunction passes the request tofetchFun.fetchFunlooks like it's probably thefetchmethod imported from thepouchdb-fetchpackage. pouchdb-fetch'sfetchexport comes from thenode-fetchpackage. Thenode-fetchdependency in PouchDB is listed as being set to version2.6.7in package.json.- The documentation for
node-fetch2.x.xis here.node-fetchadvertises itself as a "window.fetch compatible API on Node.js runtime".
With all this considered, the criteria for successfully pushing up changes to CouchDB from PouchDB are as follows.
- The HTTP request returns as
response.ok == trueaccording to howwindow.fetchwould determine a response as ok. (A truthy Response.ok is a response with status code of 2xx) - The HTTP request returns a body that can be parsed using
window.fetch'sresponse.json()method.
The contents of the response are not inspected.