Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

ipfs.files.add: cb is not a function #308

Closed
chpio opened this issue Jul 1, 2016 · 14 comments · Fixed by #314
Closed

ipfs.files.add: cb is not a function #308

chpio opened this issue Jul 1, 2016 · 14 comments · Fixed by #314
Labels

Comments

@chpio
Copy link

chpio commented Jul 1, 2016

TypeError: cb is not a function - TypeError: cb is not a function
at Object.add (/usr/src/app/node_modules/ipfs-api/lib/api/add.js:16:14)

using _Promise_s

@nginnever
Copy link
Contributor

Hello chpio! Thanks for pointing this out. Could you describe a test case when this error is thrown? Or what you are trying to add. I believe that promise should reject an error there when you provide add with invalid input.

We have a test case here in interface-ipfs-core that tests files.add promise adding a buffer.

https://github.com/ipfs/interface-ipfs-core/blob/master/src/files.js#L138

@chpio
Copy link
Author

chpio commented Jul 2, 2016

https://github.com/ipfs/js-ipfs-api/blob/master/src/api/add.js#L18

this code can only work with a cb if Promises are used there is no cb passed in.

@daviddias daviddias added the bug label Jul 2, 2016
@daviddias
Copy link
Contributor

Fixed on #309. reopen as necessary

@chpio
Copy link
Author

chpio commented Jul 2, 2016

cb is not a function, not add

@daviddias
Copy link
Contributor

@chpio you are right, fixing on: #314

@chpio
Copy link
Author

chpio commented Jul 2, 2016

offtopic: wouldn't it be better to have one basic implementation (only using callbacks) and a small wrapper for promises (requirable through var ipfsApi = require('ipfs-api/promise')(Promise);)

@daviddias
Copy link
Contributor

Could you elaborate on what 'better' would mean? Our current API comes from a consensus after many discussions and several people involved, but of course, we are always open to things to make things better :)

@chpio
Copy link
Author

chpio commented Jul 2, 2016

ok... my perspective is better = simper (in this case)

edit: simplicity is not a thing in js-ipfs-api anyway ;)

@daviddias
Copy link
Contributor

It doesn't have to be complex :), in fact, we are working towards making the code simpler and the API well documented, see:

@chpio
Copy link
Author

chpio commented Jul 3, 2016

adding is not working any more in the new version (6.0.3). 6.0.2 is working.

@chpio
Copy link
Author

chpio commented Jul 4, 2016

i thought it's a broken Promise implementation in node v4 but it's not ;(
verified by using bluebird: global.Promise = Promise;

@kenshyx
Copy link

kenshyx commented Jul 4, 2016

Can confirm this, I can't return a promise from api.add

TypeError: callback is not a function
      at Function.<anonymous> (node_modules/ipfs-api/lib/api/add.js:12:7)
      at Promise (node_modules/promisify-es6/index.js:36:20)
      at Object.add (node_modules/promisify-es6/index.js:30:16)

@chpio
Copy link
Author

chpio commented Jul 4, 2016

uhh i see now...

return promisify((files, callback) => [...]
the options argument (the 2. one) disappeared. Im calling it with {recursive: true}, is this still needed?

@kenshyx
Copy link

kenshyx commented Jul 6, 2016

Yep, the problem is that the callback receives the options if specified. I saw here 628c197 some upcoming breaking changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants