Skip to content

clearStore causes a crash when there is an active query #11846

@ach5910

Description

@ach5910

Issue Description

If client.clearStore is called while a query response is pending, it's causing a crashing at this location https://github.com/apollographql/apollo-client/blob/main/src/react/hooks/useQuery.ts#L635.

Screenshot 2024-05-15 at 9 05 37 AM

I am using

and here's how I am initializing my client

persistCacheSync({
  cache,
  storage: new MMKVWrapper(mmkvStorage),
  persistenceMapper,
  trigger: "write",
  debug: __DEV__,
});

const persistLink = createPersistLink();

const client = new ApolloClient({
  cache,
  link: from([
    persistLink,
    sentryBreadcrumbsLink,
    retryLink,
    authLink,
    tokenRefreshLink,
    errorLink,
    httpLink,
  ]),
});

I've also tried using resetStore, but I get the same error. Any feedback regarding a potential cause is greatly appreciated.

Link to Reproduction

N/A

Reproduction Steps

No response

@apollo/client version

3.9.11

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions