_bulk_get request error response #4542

Closed
czb opened this Issue Nov 4, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@czb

czb commented Nov 4, 2015

This proposal is based on

http://stackoverflow.com/questions/33500721/post-from-pouchdb-to-couchdb-via-iis-arr-reverse-proxy-ends-with-502-3-bad-gate

As it is now you check if the response is 4XX and if so you know that you cannot use '_bulk_get' because the server does not support it. Should not you accept any error as indication that the server does not like '_bulk_get'? I mean, I did not ask PouchDB to make '_bulk_get' requests so why should I deal with error messages coming from that request?

In this particular case I get 502 error and PouchDB treats it as an error that should be thrown. To me you should just accept that you got an error from the server and deactivate '_bulk_get' requests.

What do you think about it?

PS: I am sure the same goes for other check requests.

@daleharvey

This comment has been minimized.

Show comment
Hide comment
@daleharvey

daleharvey Nov 4, 2015

Member

Yeh a reverse proxy is fairly common and in this case it seems like 5XX deactivating bulkGet also would be sensible. pull requests would be very welcome

In this case the code is, https://github.com/pouchdb/pouchdb/blob/master/lib/adapters/http/index.js#L325 and we would want to make sure that the rounded error status is either 4 or 5, basically go from === 4 to === 4 || === 5 we should take the rounding out of the if statement at the same time so changing it to look like:

var status = Math.floor(err.status / 100);
if (status === 4 || status === 5) {

If you have any questions with the git workflow, hopefully we have covered them all @ https://github.com/pouchdb/pouchdb/blob/master/CONTRIBUTING.md, but if not feel free to ask. Thanks

Member

daleharvey commented Nov 4, 2015

Yeh a reverse proxy is fairly common and in this case it seems like 5XX deactivating bulkGet also would be sensible. pull requests would be very welcome

In this case the code is, https://github.com/pouchdb/pouchdb/blob/master/lib/adapters/http/index.js#L325 and we would want to make sure that the rounded error status is either 4 or 5, basically go from === 4 to === 4 || === 5 we should take the rounding out of the if statement at the same time so changing it to look like:

var status = Math.floor(err.status / 100);
if (status === 4 || status === 5) {

If you have any questions with the git workflow, hopefully we have covered them all @ https://github.com/pouchdb/pouchdb/blob/master/CONTRIBUTING.md, but if not feel free to ask. Thanks

@daleharvey

This comment has been minimized.

Show comment
Hide comment
@daleharvey

daleharvey Nov 11, 2015

Member

Fixed in c10f156

Member

daleharvey commented Nov 11, 2015

Fixed in c10f156

@daleharvey daleharvey closed this Nov 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment