stream/manage: inherit controller from parent istream if it exists

This commit is contained in:
dumbmoron 2024-06-24 17:42:29 +00:00
parent 558b6a9efd
commit ed905fd60b
No known key found for this signature in database

View file

@ -1,6 +1,7 @@
import NodeCache from "node-cache";
import { randomBytes } from "crypto";
import { nanoid } from "nanoid";
import { setMaxListeners } from "node:events";
import { decryptStream, encryptStream, generateHmac } from "../sub/crypto.js";
import { env } from "../config.js";
@ -79,7 +80,13 @@ export function createInternalStream(url, obj = {}) {
}
const streamID = nanoid();
const controller = new AbortController();
let controller = obj.controller;
if (!controller) {
controller = new AbortController();
setMaxListeners(Infinity, controller.signal);
}
internalStreamCache[streamID] = {
url,
service: obj.service,