Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MockedProvider returns error (No more mocked responses) when using cache-and-network fetchPolicy (initial render is ok but then re-render with error is triggered) #7669

Open
WojciechKulpa opened this issue Feb 8, 2021 · 1 comment

Comments

@WojciechKulpa
Copy link

WojciechKulpa commented Feb 8, 2021

Intended outcome:

MockedProvider should return correct data based on provided mocks without error.

Actual outcome:

After initial correct render components are re-rendered with error from MockedProvider (No more mocked responses for the query...)

How to reproduce the issue:

CodeSandbox: https://codesandbox.io/s/green-glitter-ynlk0
Important is fact that we are rendering two components that are using the same query with different variables.
After initial successful render components are re-rendered but this time with error about missing mock (that was returned correctly in first render). Steps after sleep are failing (without sleep test was sometimes passing if it was finished before re-render).

await findByText("Cake");
await findByText("Marshmallow");
getByText("Mints");

await sleep(50);
debug();

getByText("Cake");
getByText("Marshmallow");
getByText("Mints");

The same test works good on 3.3.0 before beta.11. Results on beta11 are a bit different than on e.g. 3.3.8 as on beta11 test are failing also in first part but starting with 3.3.0-rc.3 it looks like initial renders are ok and only first component is re-rendered with error (same behavior reproduced on 3.3.7 and 3.3.8).

Versions

3.3.0-beta.11 and later (3.3.0-beta.10 works good)

@insidewhy
Copy link

I've seen this also with apollo client 3.3.5. Doesn't it make sense though, as in, on every render it should hit the network again (since it's not cache-first). If you want to only hit the network and cache on the first render after a mount, shouldn't you set nextFetchPolicy to cache-first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants