New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash after have empty response in some xhr request in pouchDB #7019

Closed
artemmorozov7 opened this Issue Jan 17, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@artemmorozov7
Contributor

artemmorozov7 commented Jan 17, 2018

Issue

I have many crashes in app after some actions with pouchDB. I have problems to reproduce, but I have stack trace:
errorStack":"TypeError: Cannot create property 'status' on string ''\n at XMLHttpRequest.n.onreadystatechange (file:..../libs/pouchdb-6.1.2.release.js:9:20973"

I looked to stack trace, and can found place where I have exception:


I figured out what the problem was and realized that sometimes the response in this request(xhr) comes in the form of an empty string (""). In this case, JSON.parse does not work correctly and an error occurs.

Please, add check to this situation in line -

} else if (typeof xhr.response === 'string') {

} else if (typeof xhr.response === 'string' && xhr.response !== '') {
of some another check for empty string

Info

  • Environment: hybrid app
  • Platform: Android
  • Adapter: WebSQL

Reproduce

I have problems to reproduce, but I have stack trace:
errorStack":"TypeError: Cannot create property 'status' on string ''\n at XMLHttpRequest.n.onreadystatechange (file:..../libs/pouchdb-6.1.2.release.js:9:20973"

Please, if possible, fix this problem as quickly as possible, as this is the real crash for our users in application !

@artemmorozov7 artemmorozov7 changed the title from Crash after have empty responce in some xh request in pouchDB to Crash after have empty response in some xhr request in couchDB Jan 17, 2018

@artemmorozov7 artemmorozov7 changed the title from Crash after have empty response in some xhr request in couchDB to Crash after have empty response in some xhr request in pouchDB Jan 17, 2018

@daleharvey

This comment has been minimized.

Member

daleharvey commented Jan 20, 2018

Looks like you have done the investigation here and happy to accept a PR, there is a release coming soon and if the PR doesnt make it then this will be fixed by the switch to fetch anyway. If you have the time a test for this would be very helpful. Happy to help with it

artemmorozov7 pushed a commit to artemmorozov7/pouchdb that referenced this issue Jan 22, 2018

artemmorozov7 pushed a commit to artemmorozov7/pouchdb that referenced this issue Jan 22, 2018

artemmorozov7 pushed a commit to artemmorozov7/pouchdb that referenced this issue Jan 23, 2018

daleharvey added a commit that referenced this issue Jan 23, 2018

(#7019) - Crash after have empty response in some xhr request in pouchDB
* #7019 - Crash after have empty response in some xhr request in pouchDB

* #7019 - Crash after have empty response in some xhr request in pouchDB

* Crash after have empty response in some xhr request in pouchDB #7019
@daleharvey

This comment has been minimized.

Member

daleharvey commented Jan 23, 2018

Fixed in 42ca86e

@daleharvey daleharvey closed this Jan 23, 2018

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