LibWeb: Release acquired readers after piping through a stream

This very partially implements the spec's "finalize" steps for piping
streams.
This commit is contained in:
Timothy Flynn 2024-11-04 16:10:32 +01:00 committed by Andrew Kaster
parent 383d303b79
commit 4b4b12165e
Notes: github-actions[bot] 2024-12-10 03:04:00 +00:00

View file

@ -315,16 +315,18 @@ GC::Ref<WebIDL::Promise> readable_stream_pipe_to(ReadableStream& source, Writabl
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
});
auto success_steps = GC::create_function(realm.heap(), [promise, &realm, writer](ByteBuffer) {
auto success_steps = GC::create_function(realm.heap(), [promise, &realm, reader, writer](ByteBuffer) {
// Make sure we close the acquired writer.
WebIDL::resolve_promise(realm, writable_stream_default_writer_close(*writer), JS::js_undefined());
readable_stream_default_reader_release(*reader);
WebIDL::resolve_promise(realm, promise, JS::js_undefined());
});
auto failure_steps = GC::create_function(realm.heap(), [promise, &realm, writer](JS::Value error) {
auto failure_steps = GC::create_function(realm.heap(), [promise, &realm, reader, writer](JS::Value error) {
// Make sure we close the acquired writer.
WebIDL::resolve_promise(realm, writable_stream_default_writer_close(*writer), JS::js_undefined());
readable_stream_default_reader_release(*reader);
WebIDL::reject_promise(realm, promise, error);
});