From 9369dfba1146b3ae8966940a22646ba1b22162d2 Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Mon, 18 Sep 2023 09:30:07 +0100 Subject: [PATCH] fix(core): Add missing teardown handling to ssrExchange --- .changeset/old-swans-relate.md | 5 +++++ packages/core/src/exchanges/ssr.ts | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changeset/old-swans-relate.md diff --git a/.changeset/old-swans-relate.md b/.changeset/old-swans-relate.md new file mode 100644 index 0000000000..ab88f964c3 --- /dev/null +++ b/.changeset/old-swans-relate.md @@ -0,0 +1,5 @@ +--- +'@urql/core': patch +--- + +Fix missing `teardown` operation handling in the `ssrExchange`. This could lead to duplicate network operations being executed. diff --git a/packages/core/src/exchanges/ssr.ts b/packages/core/src/exchanges/ssr.ts index 2e328b4aef..10fff64cf2 100644 --- a/packages/core/src/exchanges/ssr.ts +++ b/packages/core/src/exchanges/ssr.ts @@ -222,6 +222,7 @@ export const ssrExchange = (params: SSRExchangeParams = {}): SSRExchange => { ops$, filter( operation => + operation.kind === 'teardown' || !data[operation.key] || !!data[operation.key]!.hasNext || operation.context.requestPolicy === 'network-only' @@ -236,6 +237,7 @@ export const ssrExchange = (params: SSRExchangeParams = {}): SSRExchange => { ops$, filter( operation => + operation.kind !== 'teardown' && !!data[operation.key] && operation.context.requestPolicy !== 'network-only' ),