Skip to content
// EFFECT DAYS 2026

DenoHttpServer unstable

Native Deno implementation of the Effect HttpServer.

Deno.serve can only upgrade requests to WebSocket, so other HTTP/1.1 upgrades fail. Serve them with NodeHttpServer from @effect/platform-node, which runs on Deno's node:http.

Over HTTP/1.1, Deno.serve can stop delivering the request body once the handler has returned a streamed response, so a handler that streams its response while still reading the request payload can stall (denoland/deno#36966).

Deno.serve negotiates HTTP/2 on its own: over TLS with browsers, and in cleartext with clients that request it. Deno 2.8.3 to 2.9.2 panic and exit when an HTTP/2 client cancels a request while its handler is still running (denoland/deno#36053), so this package requires Deno 2.9.3 or newer.

8 exports Since v4.0.0 Source

Constructors

make

unstable
Since v4.0.0

Creates a scoped native Deno HTTP server.

Signature

declare const make: (...args: [options: any]) => Effect<{
readonly address: SocketAddress;
readonly serve: {
<E, R>(effect: Effect<HttpServerResponse, E, R>): Effect<void, never, Scope | Exclude<R, HttpServerRequest>>;
<E, R, App extends Effect<HttpServerResponse, any, any>>(effect: Effect<HttpServerResponse, E, R>, middleware: Applied<App, E, R>): Effect<void, never, Scope | Exclude<Services<App>, HttpServerRequest>>;
};
}, ServeError, Scope>

Layers

layer

unstable
Since v4.0.0

Provides a native Deno HTTP server together with Deno HTTP services.

Signature

declare function layer(options: any): Layer<HttpPlatform | Generator | DenoServices | HttpServer, ServeError>

layerConfig

unstable
Since v4.0.0

Creates the Deno HTTP server and support-services layer from configurable options.

Signature

declare function layerConfig(options: Config<any>): Layer<Path | HttpPlatform | Generator | FileSystem | HttpServer, ServeError | ConfigError>
Since v4.0.0

Provides Deno HTTP platform services and the standard Deno service set.

Signature

declare const layerHttpServices: Layer.Layer<HttpPlatform | Etag.Generator | DenoServices.DenoServices>

layerServer

unstable
Since v4.0.0

Provides only the native Deno HTTP server.

Signature

declare const layerServer: (options: ServeOptions & {
readonly disablePreemptiveShutdown?: boolean;
readonly gracefulShutdownTimeout?: Duration.Input;
readonly websocket?: WebSocketOptions;
}) => Layer.Layer<Server.HttpServer, Error.ServeError>

Options

ServeOptions

type unstable
Since v4.0.0

Native Deno TCP, TLS, or Unix serve options managed by the scoped server.

Details

signal and onError are omitted because the scope and Effect HTTP handler own server and failure lifecycles. Server constructors additionally accept WebSocket settings that apply to every upgrade; protocol therefore cannot vary per request.

Signature

type ServeOptions = Omit<Deno.ServeTcpOptions, "signal" | "onError"> & Partial<Deno.TlsCertifiedKeyPem> | Omit<Deno.ServeUnixOptions, "signal" | "onError">

WebSocketOptions

type unstable
Since v4.1.5

WebSocket settings applied to every upgrade.

Details

Deno's upgrade options pass through to Deno.upgradeWebSocket. highWaterMark bounds the bytes of inbound messages waiting for a reader pull, including messages received before reader startup. Every message counts as at least one byte. A message that takes the queue above the limit is still queued, then the connection is closed with code 1008 and reason "Inbound message buffer limit exceeded" and later messages are discarded. Queued messages remain readable in order, followed by a SocketError wrapping a SocketReadError.

Gotchas

Inbound buffering is unbounded by default. Deno cannot pause a server WebSocket, so the limit disconnects the peer instead of slowing it down, and a peer that is still sending may not see close code 1008. The queue holds at most highWaterMark bytes plus one message, so size the limit above the largest expected burst.

Signature

type WebSocketOptions = Deno.UpgradeWebSocketOptions & {
readonly highWaterMark?: number;
}

Testing

layerTest

unstable
Since v4.0.0

Starts a Deno HTTP server on an ephemeral loopback port for tests.

Signature

declare const layerTest: Layer.Layer<Server.HttpServer | HttpPlatform | FileSystem.FileSystem | Etag.Generator | Path.Path | HttpClient>