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.

ipfs.stop(cb) not calling cb, looks like in libp2p.stop in [discovery].map.stop #1806

Closed
@mitra42

Description

@mitra42
  • Version: "0.31.7"
  • Platform: Mac OSX running node.
  • Subsystem: libp2p.stop I believe

Type: Bug

Severity: High ? The API is not working as described, (no significant impact on me)

Description:

I recently added node.stop((err, res) => debug("IPFS ended")) to my system because I was seeing that my crawl script (for archive.org) was not exiting correctly if IPFS was connected.

While this appeared to stop IPFS (the script now exits), the debug line is never called.

Using breakpoints in the IDE the problem appears to be in

  • ipfs/source/core/components/stop.js which gets the callback from self._mfsPreload.stop but not from self.libp2p.stop(cb). Digging deeper, in
  • /Users/mitra/git/dweb-mirror/node_modules/libp2p/src/index.js in stop()
    which never completes the first step in the series, i.e. the if (this._floodSub) is never called. I don't know libp2p well enough to dig deeper into the parallel code at
return parallel(
            this._discovery.map((d) => {
              return (_cb) => d.stop(() => { _cb() })
            }),
            cb
          )

To see why the cb is not called back

I suspect, from the history of similar issues in #1168 that its config dependent, Note my config includes wss and is:

{
  "repo": "/tmp/dweb_ipfsv3107",
  "config": { "Bootstrap": [ "/dns4/dweb.me/tcp/4245/wss/ipfs/QmQ921MRjsbP12fHSEDcdFeuHFg6qKDFurm2rXgA5K3RQD" ] },
  "EXPERIMENTAL": { "pubsub": true },
  "preload": {    "enabled": false  }
}

Steps to reproduce the error:

I am seeing this in a fairly complex piece of code, which I will try and strip down to its basics but to repeat it ...

git clone https://github.com/internetarchive/dweb-mirror#jsipfsissue1806
cd dweb-mirror
npm install
mkdir ~/temp/mirrored
./crawl.js 

At the end it outputs HTTP is stopped and should, but doesnt output IPFS is stopped.

I will attempt to reduce to something simpler, but I suspect that whatever causes IPFS not to exit correctly is may mean that once it is reduced that the problem goes away.

Metadata

Metadata

Assignees

Labels

P1High: Likely tackled by core team if no one steps upexp/expertHaving worked on the specific codebase is importantkind/bugA bug in existing code (including security flaws)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions