Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: kill disposable nodes on stop and simplify started status #554

Merged
merged 7 commits into from
Oct 23, 2020

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Oct 22, 2020

Fixes two problems:

  1. If we use ipfs-daemon to connect to a running node, there's no this.subprocess only this.api so don't reference that property in the this.stop() method.
  2. There's a delay between stopping the process and the process actually stopping - in CI we don't wait for this and start new tests which start new processes which can overwhelm small weak build machines so wait for the subprocess to stop before returning from this.stop()

Changes behaviour:

  1. Let the exiting of this.subprocess set this.started = false instead of when we stop the process
  2. If a node is marked disposable, we don't really care about it exiting cleanly as we're going to delete it's repo shortly afterwards so just SIGKILL it immediately.

If an `ipfsd-daemon` instance connects to a running API it does not have a
`this.subprocess` property, yet if we try to stop the node it tries to access
that property, leading to this sort of error:

```
  2) DelegatedPeerRouting
       "after all" hook in "DelegatedPeerRouting":
     TypeError: Cannot read property 'stderr' of null
      at Daemon.stop (node_modules/ipfsd-ctl/src/ipfsd-daemon.js:260:21)
      at processTicksAndRejections (node:internal/process/task_queues:93:5)
      at async Promise.all (index 0)
```

This PR moves `this.subprocess` access to where it is created and lets the
process exiting set `this.started` to `false` as otherwise the state can
get out of sync with reality.
@achingbrain achingbrain changed the title fix: kill disposable nodes immediately and fix: kill disposable nodes immediately and let the subprocess exiting decide if we are running or not Oct 22, 2020
@achingbrain achingbrain marked this pull request as ready for review October 23, 2020 12:59
Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit, otherwise this LGTM

src/ipfsd-daemon.js Outdated Show resolved Hide resolved
@achingbrain achingbrain changed the title fix: kill disposable nodes immediately and let the subprocess exiting decide if we are running or not fix: kill disposable nodes on stop and simplify started status Oct 23, 2020
@achingbrain achingbrain merged commit cd123cc into master Oct 23, 2020
@achingbrain achingbrain deleted the fix/guard-on-null-subprocess branch October 23, 2020 15:08
lidel added a commit to ipfs/ipfs-desktop that referenced this pull request Jan 20, 2021
* Allow enabling pubsub setting via tray preferences
* refactor: pubsub toggle triggers restart
* chore: ipfsd-ctl v7.2.0

ipfsd.stop() did not wait for proper shutdown, which caused things to go
racy during situations where we restart node.
When unlucky, I ended up with two go-ipfs processses.

Bumping version to include fix from ipfs/js-ipfsd-ctl#554

* fix: show pubsub status when starting
* refactor: avoid duplicated pubsub in logs

already logged in ./src/utils/create-toggler.js,
so here we only log status when app starts and that is all

* refactor: move pubsub to experiments

it is still an experiment in go-ipfs:
https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#ipfs-pubsub

* refactor: simplify pubsub enable/disable

Co-authored-by: Marcin Rataj <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants