fix: add timeout for incoming connections and build-in protocols (#1292)

Ensure that we don't wait forever for upgrading an inbound connection
to occur.

Note that transports should return an AbortableSource when passed an
AbortSignal so outbound connections to not need the same fix.

Also adds default timeouts for the ping, fetch, and identify protocols.
This commit is contained in:
Alex Potsides
2022-07-14 13:35:12 +00:00
committed by GitHub
parent b1b91398e2
commit 750ed9c35f
20 changed files with 271 additions and 148 deletions

View File

@ -19,7 +19,8 @@ import { MemoryDatastore } from 'datastore-core'
const defaultInit: FetchServiceInit = {
protocolPrefix: 'ipfs',
maxInboundStreams: 1,
maxOutboundStreams: 1
maxOutboundStreams: 1,
timeout: 1000
}
async function createComponents (index: number) {
@ -34,7 +35,8 @@ async function createComponents (index: number) {
connectionManager: new DefaultConnectionManager({
minConnections: 50,
maxConnections: 1000,
autoDialInterval: 1000
autoDialInterval: 1000,
inboundUpgradeTimeout: 1000
})
})