Skip to content

net: burst of 40k writes then end() delivers 0 bytes to a local server (Node: all 2.56 MB) #11106

Description

@proggeramlug

A net client that makes one large burst of writes and then calls end() delivers 0 bytes to a local net server. Node delivers all 2,560,000 bytes.

Found while A/B-testing tokio lane A (#11105). Base (bd9cd48da, #11083's head) and branch behave identically, so this is not caused by that PR, and it is not specific to either socket backend.

Shape

import net from "node:net";
const N = 40000, CHUNK = Buffer.alloc(64, 0x61);
const srv = net.createServer((s) => {
  let got = 0;
  s.on("data", (d) => { got += d.length; });
  s.on("end", () => { console.log("received", got); srv.close(); });
});
srv.listen(0, () => {
  const c = net.connect((srv.address() as any).port, () => {
    for (let i = 0; i < N; i++) c.write(CHUNK);
    c.end();
  });
});

Node 26.5.1 prints received 2560000. Perry prints received 0.

Likely suspects:

  • the write queue is dropped when end() arrives before it drains
  • the half-close (FIN) is sent ahead of the queued data

The fixture above is a reconstruction of the agent's probe; confirm the exact counts before minimizing further.

Activity

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