stream: avoid promise allocation for parked transform writes · nodejs/node@f81a148 · GitHub
Skip to content

Commit f81a148

Browse files
mcollinaaduh95
authored andcommitted
stream: avoid promise allocation for parked transform writes
A transform sink write arriving under backpressure parked the chunk together with a PromiseWithResolvers record whose promise was returned to the writable controller and later resolved with the perform-transform promise. The writable's write reactions already exist before the write algorithm runs, so the parked write can instead return the parked-result sentinel and have the continuation wire the perform-transform promise directly to those reactions, dropping the per-chunk promise record and the thenable adoption hop. Failures while erroring are delivered in a microtask, preserving the old rejection position. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #65625 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent aec01c5 commit f81a148

2 files changed

Lines changed: 82 additions & 19 deletions

File tree

‎lib/internal/webstreams/transformstream.js‎

Lines changed: 25 additions & 19 deletions
Lines changed: 57 additions & 0 deletions

0 commit comments

Comments
 (0)