Skip to main content
@restatedev/restate-sdk-tunnel is a preview package available since TypeScript SDK v1.15.0. Its API may change in future releases.
@restatedev/restate-sdk-tunnel lets you serve a Restate deployment over an outbound connection to Restate Cloud — no inbound HTTP listener and no public ingress into your network. It is a drop-in alternative to restate.serve(...) for services running in private networks such as a corporate VPC, a Kubernetes cluster without a public load balancer, or a developer’s laptop.

How it works

The tunnel package dials out to Restate Cloud’s tunnel servers over TLS. Restate Cloud then drives HTTP/2 over that connection — the roles are flipped compared to a normal server. Invocations arrive as HTTP/2 streams, are verified using your environment’s request-identity key, and are dispatched to your SDK handlers in-process, exactly as if they arrived on a local port. On reconnect, the tunnel dials again automatically with jittered exponential backoff.

Installation

Quick start

Once connected, register the deployment with:

Key options

Zero config on Kubernetes

When deployed via the restate-operator in tunnelMode: in-process, the operator injects the required environment variables automatically. You only need:
And a mounted API-key Secret (set RESTATE_INPROC_AUTH_TOKEN_FILE to its path). The operator injects these environment variables:

Graceful shutdown on Kubernetes

The tunnel handles SIGTERM automatically by default. On receiving SIGTERM, it:
  1. Sends an HTTP/2 GOAWAY to stop Restate Cloud from opening new streams.
  2. Lets in-flight invocations finish for up to drainGraceMs (default 120 seconds).
  3. Force-closes after the grace window and calls process.exit(0).
Set the pod’s terminationGracePeriodSeconds to at least ceil(drainGraceMs / 1000) to give the drain time to complete. To manage shutdown yourself, pass gracefulShutdown: false and call connection.shutdown() explicitly.

TunnelConnection API

connection.ready rejects if a fatal error occurs (for example, an invalid auth token). Errors that are retryable (network failures, server restarts) are handled transparently.

Comparison with restate.serve()

Requirements

  • Node.js ≥ 22
  • Restate Cloud environment with a tunnel-capable server