Skip to main content

try_sync_drain_closed_stream

Function try_sync_drain_closed_stream 

Source
pub fn try_sync_drain_closed_stream<'js>(
    stream: &Class<'js, ReadableStream<'js>>,
) -> Option<Vec<Value<'js>>>
Expand description

Fast-path drain for a default-controller ReadableStream whose queue holds all the data synchronously (e.g. the stream was enqueued in start() and then closed). Bypasses the JS reader + Promise machinery, so user code that poisons Object.prototype.then cannot swap the streamed chunks (WPT response-stream-with-broken-then).

Returns Some(chunks) if the fast path applied, None otherwise (stream locked, disturbed, has pending pull, byte controller, not yet closed, etc). Sets disturbed = true on success.