fix: reject connections when not running (#1146)

When the node is shutting down, new connections can still be received.

If this happens we can end up writing into the datastore when it's
been closed which throws an error.

Instead, if we're not running, have the connection manager close new
incoming connections.
This commit is contained in:
Alex Potsides
2022-01-26 10:52:23 +00:00
committed by GitHub
parent fc12973344
commit 902f10d58d
7 changed files with 61 additions and 7 deletions

View File

@ -403,6 +403,7 @@ describe('libp2p.upgrader', () => {
connEncryption: [Crypto]
}
})
await libp2p.start()
const echoHandler = () => {}
libp2p.handle(['/echo/1.0.0'], echoHandler)
@ -448,6 +449,8 @@ describe('libp2p.upgrader', () => {
connectionGater
})
await libp2p.start()
const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer })
// Spy on emit for easy verification