Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeJs 12.19.0 Connection dropping when sending a file that takes longer than one minute #36092

Closed
khetanir opened this issue Nov 12, 2020 · 1 comment

Comments

@khetanir
Copy link

khetanir commented Nov 12, 2020

What steps will reproduce the bug?

We've been to recreate this bug in both node:12.19.0-alpine image, and node:12.19.0 on Mac (Darwin Coyote-Tango.local 18.7.0 Darwin Kernel Version 18.7.0: Mon Apr 27 20:09:39 PDT 2020; root:xnu-4903.278.35~1/RELEASE_X86_64 x86_64).

We've setup a simple http server which waits for a request to end before responding, and we get a broken pipe after exactly 60 seconds.

Steps to recreate:

Build and run the attached Docker image:

FROM node:12.19.0-alpine
WORKDIR /opt/app-root
COPY http.js .
EXPOSE 3001
CMD [ "node", "http.js" ]

http.js:

const http = require("http");
const port = 3001;

http
  .createServer((req, res) => {
    let data = [];

    req.socket.on("close", () => console.log("req.socket.close"));
    req.socket.on("connect", () => console.log("req.socket.connect"));
    req.socket.on("drain", () => console.log("req.socket.drain"));
    req.socket.on("end", () => console.log("req.socket.end"));
    req.socket.on("error", (err) => console.error("req.socket.error", err));
    req.socket.on("lookup", () => console.log("req.socket.lookup"));
    req.socket.on("timeout", () => console.log("req.socket.timeout"));
    req.on("data", (d) => data.push(d));
    req.on("close", () => console.log("req.close"));
    req.on("end", () => {
      console.log("req.end");
      res.writeHead(200, { "Content-Type": "text/plain" });
      res.write("OK from the Server");
      return res.end();
    });
    req.on("error", (err) => {
      console.log("req.error");
      console.error(err);
    });
    res.on("close", () => console.log("res.close"));
    res.on("drain", () => console.log("res.drain"));
    res.on("error", (err) => console.log("res.error", err));
    res.on("finish", () => console.log("res.finish"));
  })
  .listen(port, () => console.log(`HTTP server listening on port ${port}`));

Steps to run:

  • docker build -t httptest .
  • docker run -p 3001:3001 httptest
  • curl --limit-rate 200K -F file=@<PATH_TO_FILE> http://localhost:3001/

Notes: Either use a reasonably large file or limit-rate so that the upload of the file takes > 60s

How often does it reproduce? Is there a required condition?

This occurs every single time on v12.19.0 - we have tested on all LTS minor/patch versions in between 12.16.3-12.19.0 and it does not occur in those versions, so the change is in 12.19.0.

Required condition: Upload taking > 60 seconds

What is the expected behavior?

Connection will continue/persist until the file upload has completed

What do you see instead?

The connection just drops, which we see when done via postman/browser/curl - we get no errors thrown in the http server.

Curl responds with the following:

curl: (55) Send failure: Broken pipe

Additional information

@Flarna
Copy link
Member

Flarna commented Nov 12, 2020

I think this is a duplicate of #35661

Should be fixed in 12.20.0 currently in preparation.

I will close this. Please reopen in case my assessment is wrong.

@Flarna Flarna closed this as completed Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants