Skip to content
Get started

Options ​

Every options type in @netifyjs/netify. "Default" is what you get when you leave the option out, and "Required" means there isn't one. Times are in milliseconds unless a row says otherwise.

Channels and sockets ​

ChannelOptions ​

Taken by every channel. Passed through childOptions on servers, options on clients and DatagramBootstrap, and channelOptions on ReliableBootstrap. See How it works.

OptionTypeDefaultWhat it does
loggerLoggerConsoleLoggerWhere the channel logs
highWaterMarknumber65536 (64 KiB)Queued bytes at which isWritable turns false
lowWaterMarknumber32768 (32 KiB)Queued bytes it drops below to turn true again
maxPendingBytesnumber67108864 (64 MiB)Queued bytes past which writes fail

SocketOptions ​

TCP settings for each connection, plus every ChannelOptions field. Passed to ServerBootstrap.childOptions. See TCP.

OptionTypeDefaultWhat it does
noDelaybooleantrueTurns Nagle off
keepAlivebooleanfalseTurns TCP keep alive on
idleTimeoutnumber0Silence before the socket closes, rounded up to whole seconds, 0 for off

ServerOptions ​

The listening socket. Passed to ServerBootstrap.options. See TCP and Safety.

OptionTypeDefaultWhat it does
tlsTLSOptionsNoneCertificates for TLS
reusePortbooleanfalseLets several processes share the port
maxConnectionsnumberNo limitOpen connections at once
maxConnectionsPerAddressnumberNo limitOpen connections from one IP

ClientOptions ​

Client socket settings, plus every SocketOptions field. Passed to Bootstrap.options.

OptionTypeDefaultWhat it does
tlsTLSOptions | booleanNonetrue for Bun's defaults, or your own settings

BindOptions ​

Passed to ServerBootstrap.bind. Either TcpBindOptions or UnixBindOptions.

OptionTypeDefaultWhat it does
hostnamestring'0.0.0.0'Interface to bind
portnumberRequiredPort, 0 for any free port
unixstringRequiredSocket path, in place of the two above

ConnectOptions ​

Passed to Bootstrap.connect. Either TcpConnectOptions or UnixConnectOptions.

OptionTypeDefaultWhat it does
hostnamestringRequiredServer host name or IP
portnumberRequiredServer port
unixstringRequiredSocket path, in place of the two above

ReconnectOptions ​

Backoff for ReconnectingClient. Bad values throw a RangeError.

OptionTypeDefaultWhat it does
initialDelaynumber100Wait before the first retry
maxDelaynumber30000Longest wait
factornumber2Multiplier per attempt, at least 1
jitternumber0.2Random spread, 0 to 1
maxAttemptsnumberNo limitFailures in a row before giving up

Datagrams ​

See UDP.

DatagramBindOptions ​

Passed to DatagramBootstrap.bind and ReliableBootstrap.bind.

OptionTypeDefaultWhat it does
hostnamestring'0.0.0.0'Interface to bind
portnumber0Port, 0 for any free port

DatagramConnectOptions ​

Passed to DatagramBootstrap.connect, plus every DatagramBindOptions field.

OptionTypeDefaultWhat it does
remoteHostnamestringRequiredPeer host name or IP
remotePortnumberRequiredPeer port

Codecs ​

See Codecs. Bad values throw a RangeError when the codec is built.

DecoderOptions ​

Passed to the ByteToMessageDecoder constructor. Every built in framing decoder takes these as well.

OptionTypeDefaultWhat it does
maxCumulationnumber16777216 (16 MiB)Bytes held while waiting for a frame
pooledbooleantrueHands frames out from a pool and takes them back after channelRead

LengthFieldOptions ​

LengthFieldBasedFrameDecoder, plus everything in DecoderOptions.

OptionTypeDefaultWhat it does
maxFrameLengthnumberRequiredLargest frame
lengthFieldOffsetnumber0Where the length field starts
lengthFieldLengthLengthFieldLengthRequiredLength field size, 1, 2, 3, 4 or 8
lengthAdjustmentnumber0Added to the length field
initialBytesToStripnumber0Bytes cut off the front of a frame
endianEndian'big'Byte order of the length field

PrependerOptions ​

LengthFieldPrepender.

OptionTypeDefaultWhat it does
lengthFieldLengthLengthFieldLengthRequiredLength field size
lengthAdjustmentnumber0Added to the body length
lengthIncludesLengthFieldLengthbooleanfalseCounts the field's own bytes
endianEndian'big'Byte order of the length field

LineOptions ​

LineBasedFrameDecoder.

OptionTypeDefaultWhat it does
maxLengthnumberRequiredLongest line
stripDelimiterbooleantrueLeaves the LF or CRLF off

DelimiterOptions ​

DelimiterBasedFrameDecoder. DelimiterBasedFrameDecoder.nulDelimiter and DelimiterBasedFrameDecoder.lineDelimiter are ready made lists.

OptionTypeDefaultWhat it does
maxFrameLengthnumberRequiredLongest frame
delimitersreadonly Uint8Array[]RequiredByte sequences that end a frame
stripDelimiterbooleantrueLeaves the delimiter off

Fixed length ​

new FixedLengthFrameDecoder(frameLength).

OptionTypeDefaultWhat it does
frameLengthnumberRequiredSize of every frame

String ​

new StringDecoder(encoding). StringEncoder takes nothing and always writes UTF-8.

OptionTypeDefaultWhat it does
encodingEncoding'utf-8'Any label TextDecoder knows

BinaryCodecOptions ​

BinaryCodec<T>.

OptionTypeDefaultWhat it does
encode(message: T) => Uint8ArrayRequiredTurns a message into bytes
decode(bytes: Uint8Array) => TRequiredTurns one frame into a message
accepts(message: unknown) => message is TRequiredPicks the messages to encode

Protobuf ​

new ProtobufCodec<T>(type, accepts).

OptionTypeDefaultWhat it does
typeProtobufTypeRequiredA protobufjs message type
accepts(message: unknown) => message is TRequiredPicks the messages to encode

MessagePack ​

new MessagePackCodec<T>(packer, accepts).

OptionTypeDefaultWhat it does
packerMessagePackerRequiredObject with pack and unpack
accepts(message: unknown) => message is TRequiredPicks the messages to encode

HttpDecoderOptions ​

HttpRequestDecoder, HttpResponseDecoder, HttpServerCodec and HttpClientCodec. See HTTP.

OptionTypeDefaultWhat it does
maxInitialLineLengthnumber4096Longest first line in bytes
maxHeaderSizenumber8192Largest header block in bytes
maxChunkSizenumber8192Largest chunk in bytes

HTTP aggregator ​

new HttpObjectAggregator(maxContentLength).

OptionTypeDefaultWhat it does
maxContentLengthnumberRequiredLargest body in bytes

WebSocketDecoderOptions ​

WebSocketFrameDecoder. See WebSocket.

OptionTypeDefaultWhat it does
expectMaskedFramesbooleanRequiredtrue on servers
maxFramePayloadLengthnumber65536 (64 KiB)Largest payload, at least 125

WebSocketEncoderOptions ​

WebSocketFrameEncoder.

OptionTypeDefaultWhat it does
maskPayloadbooleanRequiredtrue on clients

WebSocketServerOptions ​

WebSocketServerProtocolHandler. A string on its own is taken as path.

OptionTypeDefaultWhat it does
pathstringRequiredPath to upgrade on
subprotocolsreadonly string[][]Subprotocols it agrees to
maxFramePayloadLengthnumber65536 (64 KiB)Largest inbound payload

WebSocketClientOptions ​

WebSocketClientProtocolHandler. A string on its own is taken as uri.

OptionTypeDefaultWhat it does
uristringRequiredServer URL, ws, wss, http or https
subprotocolsreadonly string[][]Subprotocols to ask for, in order
headersHttpHeadersEmptyExtra headers on the upgrade request
maxFramePayloadLengthnumber65536 (64 KiB)Largest inbound payload

Handlers ​

See Handlers and Safety.

IdleOptions ​

IdleStateHandler. A negative value throws a RangeError.

OptionTypeDefaultWhat it does
readerIdlenumber0Quiet reads before an event, 0 for off
writerIdlenumber0Quiet writes before an event, 0 for off
allIdlenumber0Quiet on both sides before an event, 0 for off

Timeouts ​

new ReadTimeoutHandler(timeout) and new WriteTimeoutHandler(timeout). A value that isn't positive and finite throws a RangeError.

OptionTypeDefaultWhat it does
timeoutnumberRequiredQuiet reads, or time for one write, before closing

FlushConsolidationOptions ​

FlushConsolidationHandler.

OptionTypeDefaultWhat it does
explicitFlushAfterFlushesnumber256Flushes held during a read before one goes through
consolidateWhenNoReadInProgressbooleanfalseAlso batches flushes outside reads

TrafficShapingOptions ​

ChannelTrafficShapingHandler and GlobalTrafficShapingHandler. See Safety.

OptionTypeDefaultWhat it does
readLimitnumber0Bytes read a second, 0 for no limit
writeLimitnumber0Bytes written a second, 0 for no limit
maxDelaynumber15000Longest a single read or write waits, in ms

MetricsOptions ​

MetricsHandler. See Metrics.

OptionTypeDefaultWhat it does
timingbooleanfalseTimes the handlers after this one

Logging ​

new LoggingHandler(logger).

OptionTypeDefaultWhat it does
loggerLogger | nullThe pipeline loggerWhere it logs

OffloadOptions ​

OffloadHandler<I, O>. See Workers.

OptionTypeDefaultWhat it does
poolWorkerPool<I, O>RequiredThreads that do the work
accepts(message: unknown) => message is IRequiredPicks the messages to offload
maxInFlightnumber16Jobs per connection before reads pause

Workers and processes ​

WorkerPoolOptions ​

WorkerPool. See Workers.

OptionTypeDefaultWhat it does
scriptstring | URLRequiredScript that starts a WorkerService
workersnumberOne per coreThreads to start
maxQueuednumber1024Jobs in flight across the pool

WorkerGroupOptions ​

WorkerGroup. See Workers.

OptionTypeDefaultWhat it does
scriptstring | URLRequiredScript each thread runs
workersnumberOne per coreThreads to start
sharedSharedArrayBufferNoneMemory every thread can see
envReadonly<Record<string, string>>NoneExtra environment variables
argvreadonly string[][]Extra arguments at the end of Bun.argv

ClusterOptions ​

Cluster. See Clustering.

OptionTypeDefaultWhat it does
scriptstringRequiredEntry file, run with bun
workersnumberOne per coreProcesses to start
restartbooleantrueRestarts workers that exit
argvreadonly string[][]Arguments after the script path
envReadonly<Record<string, string>>NoneMerged over the parent's environment
stopTimeoutnumber10000Time a stopping worker gets before it's killed, in ms
readyTimeoutnumber10000Time reload waits for Cluster.ready(), in ms

Each worker gets NETIFY_WORKER, NETIFY_WORKERS and NETIFY_CLUSTER, read back with Cluster.workerId, Cluster.workerCount and Cluster.clusterId.

ShardLinkOptions ​

ShardLink.open. See Sharding.

OptionTypeDefaultWhat it does
idnumberCluster.workerId, or 0This shard
peersreadonly ShardPeer[]Unix sockets for the clusterEvery shard's address, by id
timeoutnumber5000Time a request waits for its reply, in ms
handoffTimeoutnumber30000Time a handed off player waits to be claimed, in ms
maxMessageSizenumber16777216Biggest frame of messages in bytes

Reliable UDP ​

See Reliable UDP. Bad values throw a RangeError when the handler is built.

ReliableOptions ​

ReliableHandler.

OptionTypeDefaultWhat it does
roleReliableRoleRequired'server' or 'client'
serverPacketAddressRequired on clientsServer to connect to
lanesreadonly LaneOptions[]ReliableHandler.defaultLanesLanes, the same on both ends, 1 to 127
mtunumber1200Largest packet, 256 to 65507
timeoutnumber10000Silence before a peer is dropped
keepalivenumber1000Idle time before an empty packet
ticknumber10How often resends and timeouts run
ackDelaynumber1Longest a lone ack waits
maxPeersnumber4096Peers at once
maxMessageSizenumber262144 (256 KiB)Largest message after joining fragments
maxQueuedBytesnumber4194304 (4 MiB)Bytes queued per lane before send throws
maxResendsnumber64Sends of one message before the peer is dropped
windownumber1024Reliable messages in flight per lane, 1 to 16384
congestionbooleanfalseHalves the window on loss
maxSendRatenumber0Bytes a second per peer, 0 for no limit
encryptionboolean | EncryptionOptionsfalseEncrypts data packets on both ends
simulateSimulateOptionsOffFakes loss and lag

ReliableHandler.defaultLanes is reliable-ordered on lane 0 and unreliable on lane 1.

ReliableSettings ​

Passed to ReliableBootstrap.options. It's ReliableOptions minus role and server, which the bootstrap fills in from bind or connect. Every field is optional and uses the defaults above.

LaneOptions ​

OptionTypeDefaultWhat it does
deliveryDeliveryRequired'reliable-ordered', 'reliable-unordered', 'unreliable-sequenced' or 'unreliable'

EncryptionOptions ​

Passing true for encryption is the same as passing {}.

OptionTypeDefaultWhat it does
keyPairKeyPairA fresh pairOwn X25519 keys
serverPublicKeyUint8ArrayNoneKey a client expects the server to have

SimulateOptions ​

Each field falls back to 0 once simulate is set.

OptionTypeDefaultWhat it does
lossnumber0Share of packets dropped, 0 to 1
latencynumber0Delay added to every packet
jitternumber0Extra random delay up to this
duplicatenumber0Share of packets sent twice, 0 to 1

WebSocket server ​

See WebSocket.

WebSocketBootstrapOptions ​

Passed to WebSocketBootstrap.options.

OptionTypeDefaultWhat it does
pathstringAny pathOnly upgrades requests for this path
tlsTLSOptionsNoneCertificates for wss
reusePortbooleanfalseLets several processes share the port
maxConnectionsnumberNo limitOpen connections, extras get a 503
maxPayloadLengthnumber1048576 (1 MiB)Largest message a client can send
idleTimeoutnumber120Seconds of silence before Bun closes the socket
backpressureLimitnumber16777216 (16 MiB)Bytes Bun queues before Netify holds sends
closeOnBackpressureLimitbooleanfalseCloses a socket past the limit
perMessageDeflatebooleanfalseCompresses messages
sendPingsbooleantruePings idle sockets
upgradeUpgradeHandlerAccepts everyoneChecks each request before upgrading
controlFramesbooleanfalsePasses pings and pongs to the pipeline
pooledbooleantrueReuses each channel's binary frame

WebSocketBindOptions ​

Passed to WebSocketBootstrap.bind.

OptionTypeDefaultWhat it does
hostnamestring'0.0.0.0'Interface to bind
portnumberRequiredPort, 0 for any free port

UpgradeVerdict ​

Returned from the upgrade hook. accept picks which set of fields applies.

OptionTypeDefaultWhat it does
acceptbooleanRequiredLets the client in or turns it away
dataunknownnullKept as WebSocketChannel.data, when accepted
headersHeadersInitNoneExtra headers on the 101, when accepted
statusnumber403Status to answer with, when refused

Buffers ​

See ByteBuf and Games.

QuantizerOptions ​

Quantizer. Bad values throw a RangeError.

OptionTypeDefaultWhat it does
minnumberRequiredSmallest value, lower ones are clamped
maxnumberRequiredLargest value, higher ones are clamped
bitsnumberRequiredBit width, 1 to 32

ByteBuf.allocate ​

OptionTypeDefaultWhat it does
capacitynumber256Starting size
maxCapacitynumber67108864 (64 MiB)Size it can grow to

Internal ​

These are exported but built by the framework. Every field is required.

OutboundOptions ​

OutboundBuffer, built by Channel.

OptionTypeDefaultWhat it does
highWaterMarknumberRequiredQueued bytes that turn writability off
lowWaterMarknumberRequiredQueued bytes that turn it back on
maxPendingBytesnumberRequiredQueued bytes past which writes fail
onWritabilityChanged(writable: boolean) => voidRequiredCalled on each change
onSyncRefused(error: Error) => voidNoneCalled when a sync write fails

PeerOptions ​

ReliablePeer, built by ReliableHandler from the resolved ReliableOptions.

OptionTypeDefaultWhat it does
addressPacketAddressRequiredWhere its packets go
sessionnumberRequiredSession id
saltnumberRequiredHandshake salt
lanesreadonly LaneOptions[]RequiredLane settings
mtunumberRequiredLargest packet
windownumberRequiredReliable messages in flight per lane
keepalivenumberRequiredIdle time before an empty packet
maxMessageSizenumberRequiredLargest message
maxQueuedBytesnumberRequiredBytes queued before send throws
maxResendsnumberRequiredSends before giving up
congestionbooleanRequiredCongestion control
maxSendRatenumberRequiredBytes a second, 0 for no limit

Released under the MIT licence.