Skip to content
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

Sync attachments from CouchDB : Error in fetchData function response.buffer() not a function #7688

Closed
jsantacruz-go opened this issue Mar 17, 2019 · 4 comments · Fixed by #7862

Comments

@jsantacruz-go
Copy link

Issue

Sync with attachments fails-->
fetchData throws error at calling response.buffer()

Info

  • Environment: Ionic 4, PouchDB 7.0, CouchDB 2.3.1 on Ubuntu Server
  • Platform: Android
  • Adapter: IndexedDB
  • Server: CouchDB 2.3.1

Reproduce

To reproduce this issue you have to follow this steps:

  1. Enable any DB Remote CouchdDB
  2. Save an attachment in Android PouchDB
    3 Call PouchDB.replicate.to ionic app to replicate document to Remote CouchDB
    4 Erase PouchDB on Android
    5 Replicate to new PouchDB the documents with attachments from CouchDB

I found this on the code

function fetchData(filename) {
var att = atts[filename];
var path = encodeDocId(doc._id) + '/' + encodeAttachmentId(filename) +
'?rev=' + doc._rev;
return ourFetch(genDBUrl(host, path)).then(function (response) {
if (typeof process !== 'undefined' && !process.browser) {
return response.buffer();
} else {
/* istanbul ignore next */
return response.blob();
}

So I solve this issue on my environment by forcing the response to be a blob(), I don't know if this could be a problem in other platforms, but for Ionic it works.

Also had to change (remove) some code that has a TODO comment, // TODO: Can we remove this?

For me this solve everything, my app is working fine but I think you should check that part so we can have a official working version of PouchDB for Ionic 4.

Hope I can help you in the future.

@stale
Copy link

stale bot commented May 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 16, 2019
@stale stale bot closed this as completed May 23, 2019
@CharlesGrimont
Copy link

CharlesGrimont commented May 27, 2019

Hi !

Any update about this ??????

Why its marked as wontfix ?

Thank you !

@sansato
Copy link

sansato commented May 27, 2019

See #7727

@juanes1511
Copy link

Hi, I haven't tried the solution of #7727 that posts @sansato. I think it will works..
The thing here is that I found some commented code and todo's that can be removed or changed to works with Ionic and probably other platforms.
I think the use of attachments should work no matter what, so why don't change it?

I don't know I'm kind of newbie in pouchdb so maybe you people know better about this kind of changes..

Anyway, just want to help the community..

garfieldnate added a commit to garfieldnate/pouchdb that referenced this issue Aug 2, 2019
Add a check for ReactNative next to the checks for node/browsers so that we don't throw errors using unsupported API's.

Fixes pouchdb#7688.
garfieldnate added a commit to garfieldnate/pouchdb that referenced this issue Aug 3, 2019
response.buffer() is not supported at all, and blob.type is readonly in
ReactNative. Change the limited node/browser detection to (hopefully)
feature-proof feature detection instead.

Errors fixed in RN:

    Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not
    supported

    Cannot set property type of #<Blob> which has only a getter at

Fixes pouchdb#7688 and pouchdb#7727
garfieldnate added a commit to garfieldnate/pouchdb that referenced this issue Aug 3, 2019
response.buffer() is not supported at all, and blob.type is readonly in
ReactNative. Change the limited node/browser detection to (hopefully)
feature-proof feature detection instead.

Errors fixed in RN:

    Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not
    supported

    Cannot set property type of #<Blob> which has only a getter at

Fixes pouchdb#7688 and pouchdb#7727
garfieldnate added a commit to garfieldnate/pouchdb that referenced this issue Aug 5, 2019
response.buffer() is not supported at all, and blob.type is readonly in
ReactNative. Change the limited node/browser detection to (hopefully)
future-proof feature detection instead.

Errors fixed in RN:

    Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not
    supported

    Cannot set property type of #<Blob> which has only a getter at

Fixes pouchdb#7688 and pouchdb#7727
daleharvey pushed a commit that referenced this issue Aug 7, 2019
…eactNative

response.buffer() is not supported at all, and blob.type is readonly in
ReactNative. Change the limited node/browser detection to (hopefully)
future-proof feature detection instead.

Errors fixed in RN:

    Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not
    supported

    Cannot set property type of #<Blob> which has only a getter at

Fixes #7688 and #7727
sto3psl pushed a commit to sto3psl/pouchdb that referenced this issue Mar 10, 2021
…ss in ReactNative

response.buffer() is not supported at all, and blob.type is readonly in
ReactNative. Change the limited node/browser detection to (hopefully)
future-proof feature detection instead.

Errors fixed in RN:

    Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not
    supported

    Cannot set property type of #<Blob> which has only a getter at

Fixes pouchdb#7688 and pouchdb#7727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants