Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

DenoSocket unstable

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 Since v4.0.0 Source

Constructors

fromConn

unstable
Since v4.0.0

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. servername supplies the TLS hostname; when omitted, the remote address hostname is used.

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

unstable
Since v4.0.0

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>
Since v4.0.0

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

unstable
Since v4.0.0

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

Signature

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

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 unstable
Since v4.0.0

Options for opening a TCP or Unix connection.

Signature

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

TcpOptions

type unstable
Since v4.0.0

Options for opening a TCP or Unix connection.

Signature

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

Services

Conn

unstable
Since v4.0.0

Service tag for the underlying Deno connection.

Signature

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