mirror of https://github.com/calzoneman/sync.git
fix: attempt to avoid socket leak in node >= 13.x
The default timeout was removed from the HTTP module in node 13.x: https://github.com/nodejs/node/pull/27558. I believe this is the most likely cause of fd leaks when running under current node versions.
This commit is contained in:
parent
00e9acbe4d
commit
a75917d4e4
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "3.74.2",
|
"version": "3.75.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,14 +29,15 @@ module.exports = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var path = require("path");
|
const path = require("path");
|
||||||
var fs = require("fs");
|
const fs = require("fs");
|
||||||
var https = require("https");
|
const http = require("http");
|
||||||
var express = require("express");
|
const https = require("https");
|
||||||
var Channel = require("./channel/channel");
|
const express = require("express");
|
||||||
var db = require("./database");
|
const Channel = require("./channel/channel");
|
||||||
var Flags = require("./flags");
|
const db = require("./database");
|
||||||
var sio = require("socket.io");
|
const Flags = require("./flags");
|
||||||
|
const sio = require("socket.io");
|
||||||
import LocalChannelIndex from './web/localchannelindex';
|
import LocalChannelIndex from './web/localchannelindex';
|
||||||
import { PartitionChannelIndex } from './partition/partitionchannelindex';
|
import { PartitionChannelIndex } from './partition/partitionchannelindex';
|
||||||
import IOConfiguration from './configuration/ioconfig';
|
import IOConfiguration from './configuration/ioconfig';
|
||||||
|
@ -162,8 +163,10 @@ var Server = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bind.https && Config.get("https.enabled")) {
|
if (bind.https && Config.get("https.enabled")) {
|
||||||
self.servers[id] = https.createServer(opts, self.express)
|
self.servers[id] = https.createServer(opts, self.express);
|
||||||
.listen(bind.port, bind.ip);
|
// 2 minute default copied from node <= 12.x
|
||||||
|
self.servers[id].timeout = 120000;
|
||||||
|
self.servers[id].listen(bind.port, bind.ip);
|
||||||
self.servers[id].on("error", error => {
|
self.servers[id].on("error", error => {
|
||||||
if (error.code === "EADDRINUSE") {
|
if (error.code === "EADDRINUSE") {
|
||||||
LOGGER.fatal(
|
LOGGER.fatal(
|
||||||
|
@ -176,15 +179,11 @@ var Server = function () {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.servers[id].on("clientError", function (err, socket) {
|
|
||||||
try {
|
|
||||||
socket.destroy();
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (bind.http) {
|
} else if (bind.http) {
|
||||||
self.servers[id] = self.express.listen(bind.port, bind.ip);
|
self.servers[id] = http.createServer(self.express);
|
||||||
|
// 2 minute default copied from node <= 12.x
|
||||||
|
self.servers[id].timeout = 120000;
|
||||||
|
self.servers[id].listen(bind.port, bind.ip);
|
||||||
self.servers[id].on("error", error => {
|
self.servers[id].on("error", error => {
|
||||||
if (error.code === "EADDRINUSE") {
|
if (error.code === "EADDRINUSE") {
|
||||||
LOGGER.fatal(
|
LOGGER.fatal(
|
||||||
|
@ -197,13 +196,6 @@ var Server = function () {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.servers[id].on("clientError", function (err, socket) {
|
|
||||||
try {
|
|
||||||
socket.destroy();
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue