Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
fix: add maxOutboundStreams option to connection.newStream (#415)
Browse files Browse the repository at this point in the history
When no handler has been registered for a protocol, the upgrader
falls back to the default limit of 64 streams for the protocol on
the current connection.

This PR adds a `maxOutboundStreams` option to `connection.newStream`
that gives the user a way to override the default outgoing stream
count without having to register a dummy handler.
  • Loading branch information
achingbrain authored Jun 14, 2023
1 parent 05e4418 commit 45ae18f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/interface-connection/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
metadata: Record<string, any>
}

export interface NewStreamOptions extends AbortOptions {
/**
* If specified, and no handler has been registered with the registrar for the
* successfully negotiated protocol, use this as the max outbound stream limit
* for the protocol
*/
maxOutboundStreams?: number
}

/**
* A Connection is a high-level representation of a connection
* to a remote peer that may have been secured by encryption and
Expand All @@ -172,7 +181,7 @@ export interface Connection {
tags: string[]
streams: Stream[]

newStream: (multicodecs: string | string[], options?: AbortOptions) => Promise<Stream>
newStream: (multicodecs: string | string[], options?: NewStreamOptions) => Promise<Stream>
addStream: (stream: Stream) => void
removeStream: (id: string) => void
close: () => Promise<void>
Expand Down

0 comments on commit 45ae18f

Please sign in to comment.