I know this isn't the best solution, but it works.
inputStream.pipe(decipherStream).pipe(outputStream); decipherStream.on("error", e => console.log("error", e)); decipherStream.once("close", () => outputStream.writableEnded || outputStream.end());