go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

use Fx to start and stop the host, swarm, autorelay and quicreuse

Open marten-seemann opened this issue 3 years ago • 1 comments

Fixes #2117. Part of #1993. Part of #2514.

marten-seemann avatar Feb 20 '23 09:02 marten-seemann

Thanks for removing AutoRelayHost 🎉

sukunrt avatar Sep 27 '23 05:09 sukunrt

I've added a dangling goroutine test which should be sufficient. It implicitly asserts that the connection manager is closed as the connection manager launches a background goroutine. Ideally we'd have some way to also assert that there are no scheduled timers, but I don't think we can.

When doing that, I noticed two issues:

  1. #2743.
  2. We don't shut anything down if we fail to start. But, IMO, that's not something to solve in this patch.

(I'm trying to push this forward because I don't want it to develop a bunch of merge conflicts)

Stebalien avatar Mar 19 '24 23:03 Stebalien

Thanks @Stebalien! I didn't know about uber/goleak. Looks helpful. I'll try to fix the current leaks.

MarcoPolo avatar Mar 20 '24 20:03 MarcoPolo

Hm. That goroutine should have been excluded...

Stebalien avatar Mar 20 '24 21:03 Stebalien

Oh, different nat goroutine.

Stebalien avatar Mar 20 '24 21:03 Stebalien

I'd add github.com/jackpal/go-nat-pmp.(*Client).GetExternalAddress to the exclusion list.

Stebalien avatar Mar 20 '24 21:03 Stebalien

A test that asserts the connmanager is closed after we close the host/swarm.

This is effectively covered by checking for dangling goroutines.

MarcoPolo avatar Mar 21 '24 05:03 MarcoPolo