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

docs(examples): move to webpack #335

Closed
wants to merge 5 commits into from
Closed

Conversation

dignifiedquire
Copy link
Contributor

No description provided.

@nycoliver
Copy link

nycoliver commented Aug 4, 2016

Compiles fine, but ipfs.add throws TypeError: stream.pipe is not a function and ipfs add error Error: Payload stream closed prematurely
Also in Safari SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.

The problem is here: https://github.com/ipfs/js-ipfs-api/blob/fixes-browser-add/src/get-dagnode.js#L30

Seems the response from object/get and object/data is an empty array rather than a stream.

Not sure why this is happening but here may be a clue: https://github.com/ipfs/js-ipfs-api/blob/fixes-browser-add/src/api/add.js#L19

If I send rather than sendWithTransform ipfs successfully stores object.

@nycoliver
Copy link

For some reason the response from add has two objects, the first of which has no name and no hash:
https://github.com/ipfs/js-ipfs-api/blob/master/src/add-to-dagnode-transform.js#L23

I think that's causing the TypeError: stream.pipe is not a function

Not sure where the ipfs add error Error: Payload stream closed prematurely is coming from though.

@nycoliver
Copy link

Ok, seems the stream.pipe error was due to #323, not seeing it anymore running the latest go-ipfs master. Not sure where the payload stream error is coming from.

@daviddias
Copy link
Contributor

daviddias commented Aug 8, 2016

Seems like it is a bug in go-ipfs. The file gets added through the example, but ipfs object data fails, even through go-ipfs cli:


» ipfs object data QmSpDiGm6cwbEo1WZyo1YmKH51SboG5brSLqDop4EfAh3o
# returns nothing
» ipfs cat QmSpDiGm6cwbEo1WZyo1YmKH51SboG5brSLqDop4EfAh3o
   sdfadsfas%                                                
» ipfs object get QmSpDiGm6cwbEo1WZyo1YmKH51SboG5brSLqDop4EfAh3o
{"Links":[],"Data":"\u0008\u0002\u0012\r    sdfadsfas\u0018\r"}

//cc @Kubuxu @whyrusleeping

@Kubuxu
Copy link

Kubuxu commented Aug 8, 2016

Seems to work here on the master:

 ~  ipfs add
ipfs: Reading from /dev/stdin; send Ctrl-d to stop.

Hello world! It is great day, isn't it?
ipfs: Reading from /dev/stdin; send Ctrl-d to stop.

added QmRYcKkokPSnBzwPPVcsRxhj6gGwdhGCUV2mfRRbef4X2V QmRYcKkokPSnBzwPPVcsRxhj6gGwdhGCUV2mfRRbef4X2V
 ~  ipfs cat QmRYcKkokPSnBzwPPVcsRxhj6gGwdhGCUV2mfRRbef4X2V
Hello world! It is great day, isn't it?
 ~  ipfs object data QmRYcKkokPSnBzwPPVcsRxhj6gGwdhGCUV2mfRRbef4X2V
��(Hello world! It is great day, isn't it?
�(%                                                                                                 ~  ipfs object get QmRYcKkokPSnBzwPPVcsRxhj6gGwdhGCUV2mfRRbef4X2V
{"Links":[],"Data":"\u0008\u0002\u0012(Hello world! It is great day, isn't it?\n\u0018("}
 ~  curl localhost:5001/api/v0/object/data\?arg=QmRYcKkokPSnBzwPPVcsRxhj6gGwdhGCUV2mfRRbef4X2V
��(Hello world! It is great day, isn't it?
�(%                                                                                                 ~  

I couldn't resolve your object on the network. If that is problem on specific object then please give me hash that is resolvable.

@daviddias
Copy link
Contributor

daviddias commented Aug 8, 2016

@Kubuxu it is just the files that are added through js-ipfs-api, on that specific example, that make ipfs object data fail.

Note that our tests have coverage for this and they pass, it is just this example (for 0.4.1 and 0.4.3). Which makes me think, could the example be just broken? As in, could the webpack compile step be messing with it?

@nycoliver
Copy link

Yes, it appears to be a problem with the webpack compile step... the example works by importing dist/index.js and https://wzrd.in/standalone/buffer in a script tag. However I would love to be able to just import IpfsApi from 'ipfs-api' in my webpack code, especially without running a brfs transform.

@daviddias
Copy link
Contributor

@nycoliver thank you for checking meanwhile! We got slammed yesterday with the IPFS hangouts (you are invited to join btw! https://github.com/ipfs/pm).

I do like the idea of having a pristine js-ipfs-api, just like js-ipfs, which is not poluted by assumptions of 'it can access fs', however, we are not able to pursue that change right now as many people depend on it. We might phase it out to an external module, once #305 is complete and stable :)

@nycoliver
Copy link

305 looks great, and thanks for the invitation!

I'll use ipfs-api in a script tag for now but such a hacky solution is really uncomfortable. Hoping this issue gets solved and I can bundle with webpack soon.

@nginnever
Copy link
Contributor

Also ran into this webpacking a new project using js-ipfs-api. I was able to reproduce from calling the id command however...

ipfs.id() both in promise and callback.

returns

Error: Payload stream closed prematurely

@dignifiedquire
Copy link
Contributor Author

Will wait until #390 is merged, as that makes building and things a lot simpler

@dignifiedquire
Copy link
Contributor Author

Fixed in #414

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

Successfully merging this pull request may close these issues.

5 participants