Skip to content
Effect Days 2026 Get your ticket

DenoSocket

Native Deno socket adapters for Effect sockets.

This module uses Deno-specific names: makeTcp, makeTcpChannel, layerTcp, and fromConn correspond to the Node platform's net and duplex APIs. Deno does not support keepAliveInitialDelay, and the noDelay and keepAlive options have no effect on Unix connections. A CloseEvent always closes gracefully because Deno has no equivalent of Node's reset-on-close.

9 exports Added in v4.0.0 Source

Constructors

fromConn

Added in v4.0.0 Source

Adapts a Deno connection into an Effect socket.

Details

Readers over TCP connections can upgrade in place with Deno.startTls. Deno exposes only the client side of this transition; Unix connections fail the upgrade with a SocketUpgradeError.

Deno.startTls does not support client certificates, so key, cert, passphrase, and requestCert do not affect Deno upgrades. Setting rejectUnauthorized to false disables hostname verification only; certificate-chain validation still applies.

Signature

declare function fromConn<RO>(open: Effect<Conn, SocketError, RO>): Effect<Socket, never, Exclude<RO, Scope>>

makeTcp

Added in v4.0.0 Source

Opens a native Deno TCP or Unix connection as an Effect socket.

Details

An openTimeout interrupts acquisition but cannot cancel the in-flight Deno.connect promise. The scope finalizer closes a connection that arrives after the timeout.

Signature

declare function makeTcp(options: any): Effect<Socket>

Creates a channel over a native Deno TCP or Unix connection.

Signature

declare function makeTcpChannel<IE = never>(options: any): Channel<readonly [Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>], SocketError | IE, void, readonly [string | Uint8Array<ArrayBufferLike> | CloseEvent, string | Uint8Array<ArrayBufferLike> | CloseEvent], IE>

Layers

layerTcp

Added in v4.0.0 Source

Provides a socket by opening a native Deno TCP or Unix connection.

Signature

declare const layerTcp: (options: ConnectOptions) => Layer.Layer<Socket.Socket, Socket.SocketError>

Creates a socket layer connected to a URL with Deno's global WebSocket.

Signature

declare function layerWebSocket(url: string, options?: {
readonly highWaterMark?: number;
readonly openTimeout?: Input;
readonly protocols?: string | Array<string>;
}): Layer<Socket>

Provides the WebSocket constructor backed by globalThis.WebSocket.

Signature

declare const layerWebSocketConstructor: Layer.Layer<Socket.WebSocketConstructor>

Options

ConnectOptions type

Added in v4.0.0 Source

Options for opening a TCP or Unix connection.

Signature

type ConnectOptions = Deno.ConnectOptions | Deno.UnixConnectOptions & {
readonly keepAlive?: boolean;
readonly noDelay?: boolean;
}

TcpOptions type

Added in v4.0.0 Source

Options for opening a TCP or Unix connection.

Signature

type TcpOptions = ConnectOptions & {
readonly openTimeout?: Duration.Input;
}

Services

Conn

Added in v4.0.0 Source

Service tag for the underlying Deno connection.

Signature

declare class Conn extends Shape<"@effect/platform-deno/DenoSocket/Conn", Conn, this> {
constructor(_: never);
}