MCPcopy Create free account
hub / github.com/awslabs/llrt / source_cancel_algorithm

Function source_cancel_algorithm

modules/llrt_stream_web/src/transform/stream.rs:328–350  ·  view source on GitHub ↗
(
    ctx: Ctx<'js>,
    stream_class: &TransformStreamClass<'js>,
    controller_class: &TransformStreamDefaultControllerClass<'js>,
    reason: Value<'js>,
)

Source from the content-addressed store, hash-verified

326 controller::transform_stream_set_backpressure(&ctx, stream_class, false)
327}
328
329pub(crate) fn source_cancel_algorithm<'js>(
330 ctx: Ctx<'js>,
331 stream_class: &TransformStreamClass<'js>,
332 controller_class: &TransformStreamDefaultControllerClass<'js>,
333 reason: Value<'js>,
334) -> Result<Promise<'js>> {
335 let cancel_promise = controller::perform_cancel(ctx.clone(), controller_class, reason.clone())?;
336
337 let sc = stream_class.clone();
338 let cc = controller_class.clone();
339 crate::utils::promise::upon_promise::<Value<'js>, _>(
340 ctx.clone(),
341 cancel_promise,
342 move |ctx, result| {
343 cc.borrow_mut().clear_algorithms();
344 controller::transform_stream_error_writable_and_unblock_write(&sc, reason)?;
345 match result {
346 Ok(_) => Ok(Value::new_undefined(ctx)),
347 Err(r) => Err(ctx.throw(r)),
348 }
349 },
350 )
351}

Callers 1

callMethod · 0.85

Calls 4

perform_cancelFunction · 0.85
clear_algorithmsMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected