mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-12 10:47:13 +00:00
fix: transport manager fault tolerance should include tolerance to transport listen fail (#893)
This commit is contained in:
parent
4ee3e1973b
commit
3f314d5e90
@ -196,7 +196,7 @@ class TransportManager {
|
|||||||
// listening on remote addresses as they may be offline. We could then potentially
|
// listening on remote addresses as they may be offline. We could then potentially
|
||||||
// just wait for any (`p-any`) listener to succeed on each transport before returning
|
// just wait for any (`p-any`) listener to succeed on each transport before returning
|
||||||
const isListening = results.find(r => r.isFulfilled === true)
|
const isListening = results.find(r => r.isFulfilled === true)
|
||||||
if (!isListening) {
|
if (!isListening && this.faultTolerance !== FAULT_TOLERANCE.NO_FATAL) {
|
||||||
throw errCode(new Error(`Transport (${key}) could not listen on any available address`), codes.ERR_NO_VALID_ADDRESSES)
|
throw errCode(new Error(`Transport (${key}) could not listen on any available address`), codes.ERR_NO_VALID_ADDRESSES)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ describe('libp2p.transportManager (dial only)', () => {
|
|||||||
throw new Error('it should fail to start if multiaddr fails to listen')
|
throw new Error('it should fail to start if multiaddr fails to listen')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not fail to start if multiaddr fails to listen when supporting dial only mode', async () => {
|
it('does not fail to start if provided listen multiaddr are not compatible to configured transports (when supporting dial only mode)', async () => {
|
||||||
libp2p = new Libp2p({
|
libp2p = new Libp2p({
|
||||||
peerId,
|
peerId,
|
||||||
addresses: {
|
addresses: {
|
||||||
@ -226,4 +226,22 @@ describe('libp2p.transportManager (dial only)', () => {
|
|||||||
|
|
||||||
await libp2p.start()
|
await libp2p.start()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('does not fail to start if provided listen multiaddr fail to listen on configured transports (when supporting dial only mode)', async () => {
|
||||||
|
libp2p = new Libp2p({
|
||||||
|
peerId,
|
||||||
|
addresses: {
|
||||||
|
listen: [multiaddr('/ip4/127.0.0.1/tcp/12345/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3/p2p-circuit')]
|
||||||
|
},
|
||||||
|
transportManager: {
|
||||||
|
faultTolerance: FaultTolerance.NO_FATAL
|
||||||
|
},
|
||||||
|
modules: {
|
||||||
|
transport: [Transport],
|
||||||
|
connEncryption: [Crypto]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await libp2p.start()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user