ipfs-blob-store icon indicating copy to clipboard operation
ipfs-blob-store copied to clipboard

file not available when writestream ends

Open hackergrrl opened this issue 9 years ago • 3 comments

File not found by the time the stream ends. (Using the cb param on createWriteStream works though)

var ws = store.createWriteStream({
  key: 'cookso'
})

ws.write('hello world\n')
ws.end(function () {
  var rs = store.createReadStream({
    key: 'cookso'
  })

  rs.pipe(process.stdout)
})

hackergrrl avatar Mar 29 '16 19:03 hackergrrl

the streams gets buffered and then sent through js-ipfs-api, which causes your callback to fire while the request is being made, causing a racing condition with your read. Makes sense?

daviddias avatar Mar 29 '16 19:03 daviddias

This is the same issue we had with idb-blob-store. You can see a solution to this in idb-plus-blob-store.

dignifiedquire avatar Mar 30 '16 19:03 dignifiedquire

@diasdavid: You mean go-ipfs is closing the stream before flushing? That HTTP request to go-ipfs shouldn't be closing until it's flushed it to disk.

@dignifiedquire: I think this might be something different? Do you have a write-up on that?

hackergrrl avatar Apr 02 '16 12:04 hackergrrl