Interface NewStreamOptions

An object that contains an AbortSignal as the optional signal property.

Example

const controller = new AbortController()

aLongRunningOperation({
signal: controller.signal
})

// later

controller.abort()
interface NewStreamOptions {
    maxOutboundStreams?: number;
    negotiateFully?: boolean;
    runOnTransientConnection?: boolean;
    signal?: AbortSignal;
}

Hierarchy (view full)

Properties

maxOutboundStreams?: number

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

negotiateFully?: boolean

By default when negotiating a protocol the dialer writes then protocol name then reads the response.

When a only a single protocol is being negotiated on an outbound stream, and the stream is written to before being read from, we can optimistically write the protocol name and the first chunk of data together in the first message.

Reading and handling the protocol response is done asynchronously, which means we can skip a round trip on writing to newly opened streams which significantly reduces the time-to-first-byte on a stream.

The side-effect of this is that the underlying stream won't negotiate the protocol until either data is written to or read from the stream so it will not be opened on the remote until this is done.

Pass false here to optimistically write the protocol name and first chunk of data in the first message.

If multiple protocols are being negotiated, negotiation is always completed in full before the stream is returned so this option has no effect.

Default

true
runOnTransientConnection?: boolean

Opt-in to running over a transient connection - one that has time/data limits placed on it.

Default

false
signal?: AbortSignal