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

[Question] How to properly and quickly end an ongoing files.get stream ? #1018

@ya7ya

Description

@ya7ya
  • Version: 0.26.0
  • Platform: Browser (Chrome)
  • Subsystem: files.get , ipfs-bitswap

Type: Question

Severity: Low

Description:

How to properly end an ongoing files stream from files.get ? I already tried end() and destroy() but when looking at the bitswap module. I can still see blocks in the wantlist and blocks being received. So I also tried using _bitswap.unwant(cids) and even went a little deeper and tried ipfs._bitswap.wm.cancelWants(cids) but blocks keep on coming.

So What's the proper way to end the file(s) stream.??

Steps to reproduce the error:

go to example exchange files in browser

add the following after line 85

  node.files.get(multihash, (err, filesStream) => {
    if (err) {
      return onError(err)
    }

    filesStream.on('data', (file) => {
      // stopping stream(s)
     if (file.content) {
       file.content.destroy()
       fileStream.destroy()
       setTimeout(() => {
          node._bitswap.engine.ledgerMap.forEach((ledger, peerId, ledgerMap) => {
             console.log(`${peerId} : ${JSON.stringify(ledger.accounting)}\n`)
          })
      }, 3000)
     }

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportA question or request for support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions