LibWeb: Register shutdown-on-close handler once in ReadableStreamPipeTo

Previously, we added a `reader.closed()` promise reaction during every
`ReadableStreamPipeTo::process()` call, which meant allocating a new
reaction objects for every processed chunk and retaining all of them
until the stream closed. The same issue existed for `writer.closed()`
inside `ReadableStreamPipeTo::read_chunk()`.

This change registers a single shutdown handler for both the reader and
the writer in the ReadableStreamPipeTo constructor.
This commit is contained in:
Aliaksandr Kalenik
2025-12-08 18:53:33 +01:00
committed by Tim Flynn
parent d852b59d99
commit 2e9c8ab669
Notes: github-actions[bot] 2025-12-08 18:58:39 +00:00
2 changed files with 14 additions and 17 deletions

View File

@@ -71,6 +71,8 @@ private:
GC::Ptr<WebIDL::Promise> m_last_write_promise;
Vector<JS::Value, 1> m_unwritten_chunks;
GC::Ref<WebIDL::ReactionSteps> m_on_shutdown;
bool m_prevent_close { false };
bool m_prevent_abort { false };
bool m_prevent_cancel { false };