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

(core) - fix issue with ssr-exchange looping for reexecuted ops #1944

Merged
merged 1 commit into from
Sep 11, 2021

Conversation

JoviDeCroock
Copy link
Collaborator

Resolves #1888

Summary

When an operation would get reexecuted due to staleWhileRevalidate: true it would keep on hitting this branch as we don't filter out network-only results from the ssrCache response

Set of changes

  • Guard against infinite loops within the ssrExchange

@changeset-bot
Copy link

changeset-bot bot commented Sep 11, 2021

🦋 Changeset detected

Latest commit: 626e918

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -128,8 +130,9 @@ export const ssrExchange = (params?: SSRExchangeParams): SSRExchange => {
map(op => {
const serialized = data[op.key]!;
const result = deserializeResult(op, serialized);
if (staleWhileRevalidate) {
if (staleWhileRevalidate && !revalidated.has(op.key)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this made me think whether or not we should guard for this on line 129 by doing filter(operation => !!data[operation.key] && operation.context.requestPolicy !== "network-only"),

@JoviDeCroock JoviDeCroock merged commit 63eec7e into main Sep 11, 2021
@JoviDeCroock JoviDeCroock deleted the ssr-exchange-loop branch September 11, 2021 20:02
@urql-ci urql-ci mentioned this pull request Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If staleWhileRevalidate is set to true, it crashs Next.js and the page keeps loading forever
2 participants