Ensure streams and destroyed on end of /stream request to see if addressess TCP leak issue (#175)

This commit is contained in:
Simon J
2023-10-09 16:19:00 +11:00
committed by GitHub
parent 9786d9f1dd
commit fb5f8e81ec
6 changed files with 53 additions and 13 deletions

View File

@@ -58,6 +58,8 @@ const asBoolean = (value: string) => value == "true";
const asInt = (value: string) => Number.parseInt(value);
const asStringNoTrailingSlash = (value: string) => value.replace(/\/$/, "");
export default function () {
const port = bnbEnvVar<number>("PORT", { default: 4534, parser: asInt })!;
const bonobUrl = bnbEnvVar("URL", {
@@ -98,7 +100,8 @@ export default function () {
sid: bnbEnvVar<number>("SONOS_SERVICE_ID", { default: 246, parser: asInt }),
},
subsonic: {
url: bnbEnvVar("SUBSONIC_URL", { legacy: ["BONOB_NAVIDROME_URL"], default: `http://${hostname()}:4533` })!,
// todo: why isnt this a url like bonobUrl above?
url: bnbEnvVar("SUBSONIC_URL", { legacy: ["BONOB_NAVIDROME_URL"], default: `http://${hostname()}:4533`, parser: asStringNoTrailingSlash })!,
customClientsFor: bnbEnvVar<string>("SUBSONIC_CUSTOM_CLIENTS", { legacy: ["BONOB_NAVIDROME_CUSTOM_CLIENTS"] }),
artistImageCache: bnbEnvVar<string>("SUBSONIC_ARTIST_IMAGE_CACHE"),
},

View File

@@ -450,8 +450,11 @@ function server(
.forEach(([header, value]) => {
res.setHeader(header, value!);
});
if (sendStream) stream.stream.pipe(filter).pipe(res);
else res.send();
res.on('close', () => {
stream.stream.destroy()
});
if (sendStream) stream.stream.pipe(filter).pipe(res)
else res.send()
});
};