Node.js管道内存大幅增加

时间:2019-11-18 15:40:27

标签: node.js

我正在使用Nodejs管道将数据从其他服务器发送到客户端,但是nodejs的内存使用量每分钟都在增加,我不知道为什么。

app.use("/", function(req, res) {
  try {
    var serviceAddress = "http://example.com";
    req
      .pipe(
        request(serviceAddress, function(error, response, body) {
          if (error) {
            console.log("error:", error);
            res.status(410).end();
          }
        }),
      )
      .pipe(res)
      .on("error", function(e) {
        console.log("***Error in pipe:\r\n" + e);
        res.destroy();
      });
  } catch (ex) {
    console.log("***Error in run: \r\n" + ex);
    res.status(410).end();
  }
});
app.listen(81, () => {});

0 个答案:

没有答案