From 465ccfec40a23601894860ec3ebcee6b78af09e4 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 11 Nov 2023 20:44:00 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/smartstream.classes.smartduplex.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 098c582..8fcbe73 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartstream', - version: '3.0.16', + version: '3.0.17', description: 'simplifies access to node streams' } diff --git a/ts/smartstream.classes.smartduplex.ts b/ts/smartstream.classes.smartduplex.ts index 739ceb7..cbfa6a5 100644 --- a/ts/smartstream.classes.smartduplex.ts +++ b/ts/smartstream.classes.smartduplex.ts @@ -129,12 +129,15 @@ export class SmartDuplex extends Duplex { } } + public notBackpressured = true; public push(chunkArg?: TOutput | null): boolean { const result = super.push(chunkArg); if (!result && this.handleBackpressure) { + this.notBackpressured = false; this.pause(); // Listen for 'drain' event to resume this.once('drain', () => { + this.notBackpressured = true; this.resume(); // Resume the source of data }); } @@ -164,6 +167,7 @@ export class SmartDuplex extends Duplex { } catch (err) { callback(err); } + return this.notBackpressured; } public async _final(callback: (error?: Error | null) => void) {