If the peer thread finishes connecting after the shutdown flag is set, it misses the flag and blocks in the read loop until the 60s p2p read timeout instead of exiting. Shows up in CI as intermittent node did not exit within 45s after stop.
Set up a mock peer that holds the handshake open until stop, then completes it -> here
INFO net Connected to Address { ... }
INFO node DBG net: connected, stored writer, running=false
panicked: node did not exit within 20s
running is already false when the thread finishes connecting, but nothing between the handshake and the read loop re-checks it.
I believe the expected behavior should be every worker observes the flag and exits within ~1–2s regardless of connection timing.
If the peer thread finishes connecting after the shutdown flag is set, it misses the flag and blocks in the read loop until the 60s p2p read timeout instead of exiting. Shows up in CI as intermittent
node did not exit within 45s after stop.Set up a mock peer that holds the handshake open until stop, then completes it -> here
runningis alreadyfalsewhen the thread finishes connecting, but nothing between the handshake and the read loop re-checks it.I believe the expected behavior should be every worker observes the flag and exits within ~1–2s regardless of connection timing.