Skip to content

Data races on resource #379

@falentio

Description

@falentio

Describe the bug

current implementations use loading state per resource instance rather than per fetch.
It can be avoided using unique id/timestamp per fetch, and make the loadings become Map<string, boolean>

Reproduction

let foo = $state("")
const rs = resource(() => foo, async (foo, _, { signal }) => fetch(foo, { signal }))
// repeatedly assign foo, user input in search
foo = search

this will lead the loading to false

Logs

System Info

-

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    triagePending triage by a maintainer to give it proper labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions