cloudflare / cloudflare/workerd

🐛 Bug Report — ports on Windows

Open
#1,664 1 comment 2 reactions 0 assignees View on GitHub
bug local dev
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

On Windows, `workerd` silently ignores Address in use errors when trying to bind to an already occupied port.

Using the following capnp:

```
using Workerd = import "/workerd/workerd.capnp";

const config :Workerd.Config = (
services = [
( name = "main", worker = .worker ),
],
sockets = [
( name = "http", address = "127.0.0.1:8080", http = (), service = "main" ),
]
);

const worker :Workerd.Worker = (
modules = [
( name = "index.mjs",
esModule =
`export default {
` async fetch(request, env, ctx) {
` return new Response("body");
` }
`}
)
],
compatibilityDate = "2023-02-28",
);
```

When running two `workerd` processes, the first successfully binds to `8080`, and is accessible from a browser. The second `workerd` process also reports that it's successfully bound to `8080`, but is not accesible from a browser.

On macOS or Linux, the second `workerd` process crashes with:

```
*** Fatal uncaught kj::Exception: kj/async-io-unix.c++:945: failed: ::bind(sockfd, &addr.generic, addrlen): Address already in use; toString() = 127.0.0.1:8080
```

cc @mrbbot @RamIdeas

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.