Skip to content

Unstable UDP listener does not provide reusePort/SO_REUSEPORT option, all traffic on one thread #36858

Open

Description

@ZombieB1309

As described. The Deno.listenDatagram API does not provide the SO_REUSEPORT socket option.

Looking through some other issues and code comments shows that it isn't available due to cross-platform compatibility. I think it would be convenient to have this available, at least on Linux. I'm not so sure about how Deno handles I/OCP on Windows, though it would also be a nice-to-have. Deno.TcpListenOptions already implements reusePort.

const workerId = crypto.randomUUID();

const listener = Deno.listenDatagram({
    transport: "udp",
    port: 3000,
    hostname: "127.0.0.1",
    reusePort: true
}); // across several worker threads

const cb = (d: Uint8Array<ArrayBufferLike>, a: Deno.Addr) => {
    console.log(`(${workerId}) ${d.byteLength} from ${a.hostname}:${a.port}`);
}
const loop = () => {
    listener.receive().then(([d, a]) => cb(d, a)).finally(loop);
};
loop();

Activity

  1. changed the title [-]Unstable UDP listener does not provide `reusePort`/`SO_REUSEPORT` option[/-] [+]Unstable UDP listener does not provide `reusePort`/`SO_REUSEPORT` option, all traffic on one thread[/+] on Sep 17, 2026
  2. ZombieB1309 commented on Sep 17, 2026

    @ZombieB1309
    Author

    Looking at the source more closely. set_reuse_port is set explicitly but I'm seeing all traffic go to one thread.

  3. Tiancheng-Xu commented on Sep 17, 2026

    @Tiancheng-Xu
    Contributor

    I can investigate the missing reusePort / SO_REUSEPORT option for unstable UDP listeners. I will reproduce the current listener behavior, trace the platform-specific socket setup, and add focused regression coverage with the smallest compatible change if confirmed. I will report the validation results in the PR.

  4. ZombieB1309 commented on Sep 18, 2026

    @ZombieB1309
    Author

    Update: I was able to compile with set_reuse_port set without set_reuse_addr in net_listen_udp and it seems to work. It now seems like set_reuse_addr is causing the thread exclusivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions