Skip to content

Commit

Permalink
fix executing standby queries in ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
atarek12 committed Jan 31, 2022
1 parent 4c7b4c1 commit c545a57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/react/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function useQuery<

if (
context.renderPromises &&
options?.fetchPolicy !== "standby" &&
options?.ssr !== false &&
!options?.skip &&
obsQuery.getCurrentResult().loading
Expand Down
9 changes: 8 additions & 1 deletion src/react/ssr/RenderPromises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ export class RenderPromises {
// as getting stuck in an infinite rendering loop because we kept calling
// queryInstance.fetchData for the same Query component indefinitely.
this.lookupQueryInfo(queryInstance).seen = true;
promises.push(promise);
// neglect all queries that are not ready in SSR to prevent waiting forever
if (
queryInstance?.fetchPolicy !== "standby" ||
queryInstance?.ssr !== false ||
!queryInstance?.skip
) {
promises.push(promise);
}
});
this.queryPromises.clear();
return Promise.all(promises);
Expand Down

0 comments on commit c545a57

Please sign in to comment.