Skip to content

RAN011 Async value created and read in the owner that replaces it

warning RAN011: report is created inside createSuspense's body and read there; each run of the body disposes report and starts a new flight.

Cause. An owner body (a boundary, an owning memo, an effect, createAsyncWith) disposes the nodes it created before each re-run. An async value created and read in the same body is replaced on every settle: the boundary shows its fallback forever and starts a flight per settle.

Fix. Create the async value outside the owner and read it inside.

Triggers

module Example

open System.Threading.Tasks
open Ranvier

let view () =
    createSuspense (fun _ -> 0) (fun () ->
        let report = createAsync (fun _ _ -> Task.FromResult 1)
        report.Value)

Fixed

module Example

open System.Threading.Tasks
open Ranvier

let view () =
    let report = createAsync (fun _ _ -> Task.FromResult 1)
    createSuspense (fun _ -> 0) (fun () -> report.Value)

Suppression. // fsharpanalyzer: ignore-line RAN011, with the reason on the line before.

Edit this page