Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

files.cat stream doesn't auto resume .on('data') #939

Closed
kevinsimper opened this issue Jul 28, 2017 · 4 comments
Closed

files.cat stream doesn't auto resume .on('data') #939

kevinsimper opened this issue Jul 28, 2017 · 4 comments
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now

Comments

@kevinsimper
Copy link

I wrote this simple demo on jsbin, but somehow the content stream does not emit any data?

I would love to see such a simple demo here in the repo and I will submit a pull request if wanted to this repo

https://jsbin.com/covirovuxe/edit?html,output

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<script src="https://unpkg.com/ipfs/dist/index.min.js"></script>
  <script>
  const node = new Ipfs()

node.on('ready', () => {
  // Your node is now ready to use \o/

console.log('ready')
node.files.get('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG', (err, data) => {
  console.log(err, data)
  data.on('data', (file) => {
    console.log(file)
    
    if(!file.content) return
    // write the file's path and contents to standard out
    file.content.on('data', function (chunk) {
      console.log(chunk)
      
      
    })
    
    file.content.on('error', function (error) {
      console.log(error)
    })
    
    file.content.on('end', function () {
      console.log('no more data')
    })
  })
})
})
  </script>
</body>
</html>
@daviddias
Copy link
Member

I've seen this issue before as the stream doesn't resume for some reason. Try manually resuming it with .resume(), example:

https://github.com/ipfs/js-ipfs/blob/master/examples/exchange-files-in-browser/public/js/app.js#L84-L107

@daviddias daviddias added kind/bug A bug in existing code (including security flaws) kind/support A question or request for support P3 Low: Not priority right now labels Aug 1, 2017
@kevinsimper
Copy link
Author

That is weird that it works different, the first behaves like it should where when you attach a callback to data it begins streaming.

@daviddias daviddias changed the title Stream in browser does not emit data files.cat stream doesn't auto resume .on('data') Sep 1, 2017
@daviddias daviddias added exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue and removed kind/support A question or request for support labels Sep 1, 2017
@daviddias daviddias added the status/ready Ready to be worked label Sep 13, 2017
@daviddias
Copy link
Member

Hi @kevinsimper, mind confirming if this is still an issue? I haven't seen it again with 0.27

@daviddias
Copy link
Member

Closing as I can't repro. Let me know if you still see the bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P3 Low: Not priority right now
Projects
None yet
Development

No branches or pull requests

2 participants