Skip to main content

Deno Deploy Beta 2


Deno Deploy is a multi-tenant JavaScript engine running in 25 data centers across the world. The service deeply integrates cloud infrastructure with the V8 virtual machine, allowing users to quickly script distributed HTTPS servers. This novel “serverless” system is designed from the ground up for modern JavaScript programming.

Today we are releasing Deploy Beta 2. This is the second in a series of beta releases that will be made over the coming months. Each release will add features and refine the programming model. The releases will culminate in a General Availability announcement that we estimate will happen in Q4 2021.

Over the past eight months, we have been quietly designing this hosted service to supplement workflows with the open source Deno CLI. Deploy does not run on AWS Lambda nor does it use Cloudflare Workers; this is a new system with a unique design. We encourage people to look past the rough initial UI and explore this new JavaScript runtime.

Deploy’s goal is to be the best place to host modern server-side JavaScript.

Static files can be loaded using Deno.readFile

Since the release of Deploy Beta 1, many users have created API endpoints and edge proxies using Deploy. Many other use-cases require static assets like images, markdown, and CSS. Previously we’ve suggested that users load static content by making outbound fetch() requests to their GitHub repositories and proxying the content through.

Beta 2 now greatly simplifies this by adding the Deno.readFile API. This API can be used to load static files stored in a deployments linked GitHub repository.

const image = await Deno.readFile("./static/logo.png");
addEventListener("fetch", (e) => {
  e.respondWith(
    new Response(image, {
      headers: { "Content-Type": "image/png" },
    }),
  );
});

You can read more about the Deno.readFile API in the documentation.

Because Deploy now has a file system, import.meta.url has been updated to a file:// URL for all new projects. Existing projects will continue to work as before. To use the new behavior, create a new project.

Deno.listen and Deno.serveHttp

We are working towards bringing Deno Deploy and Deno CLI closer together so that code on one system is transparently interoperable with the other. Previously the only way to handle incoming requests in Deploy was using addEventListener("fetch", cb). We have now added the ability to use CLI-compatible calls Deno.listen() and Deno.serveHttp() to handle requests. This allows web frameworks like Oak to transparently support Deploy.

const listener = Deno.listen({ port: 0 });
console.log("listening on port", listener.addr.port);

async function handleConn(conn) {
  const httpConn = Deno.serveHttp(conn);
  for await (const e of httpConn) {
    e.respondWith(handler(e.request, conn));
  }
}

function handler(_request, conn) {
  return new Response("ok", {
    headers: {
      "x-localaddr": `${conn.localAddr.hostname}:${conn.localAddr.port}`,
      "x-remoteaddr": `${conn.remoteAddr.hostname}:${conn.remoteAddr.port}`,
    },
  });
}

for await (const conn of listener) {
  handleConn(conn);
}

Crash reports

Update 7th Feb 2023: the feature is no longer available in deploy.

Deploy already has streaming log support, which allows viewing output from instances worldwide in real-time. However when a Deno Deploy instance crashes it can be difficult to spot in the logs, especially for projects with a lot of traffic. Thus we’ve added persistent “Crash Reports” which consist of the 100 lines of logs before any unhandled exception.

New Design

The Deploy dashboard website has had a complete visual redesign, with better navigation and accessibility.

What’s Next

We will continue to improve Deploy in upcoming beta releases, culminating in a GA release that is expected in Q4 2021. Expect the next release to address long-requested cache features, CLI interoperability, and a better getting-started flow.