Skip to content

Possible bug in initiate() promise resolution timing #2645

@markerikson

Description

@markerikson

While testing upsertQueryData, I was doing something like this:

const fetchRes = dispatch(post.initiate('3'))
const upsertRes = dispatch(upsert('post', '3', {obj}))

await upsertRes;
expect(data).toEqual(upsertedData)

await fetchRes
expect(data).toEqual(fetchedData)

including a queryFn that was supposed to wait some delay before resolving.

Except it never worked. when I added a bunch of logging, the upsert did indeed update the state first, then the fetch, but somehow the upsertRes promise never resolved until the fetch update was complete. I couldn't figure out if it was a problem with my test code, or the "running promises" logic.

This may be related to #2477 / #2481 in some way, or it could be a different promises bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions