Skip to content

Commit

Permalink
fix(auth): Fix authExchange’s retry queue ignoring teardowns (#3235)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten authored May 31, 2023
1 parent c356285 commit 9bf5583
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-eagles-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@urql/exchange-auth': patch
---

Fix regression that caused teardowns to be ignored by an `authExchange`’s retry queue.
19 changes: 6 additions & 13 deletions exchanges/auth/src/authExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,13 @@ export function authExchange(
return config ? config.addAuthToOperation(operation) : operation;
}

const teardownOps$ = pipe(
operations$,
filter(operation => operation.kind === 'teardown')
);

const pendingOps$ = pipe(
operations$,
filter(operation => operation.kind !== 'teardown')
);

const opsWithAuth$ = pipe(
merge([retries.source, pendingOps$]),
merge([retries.source, operations$]),
map(operation => {
if (
if (operation.kind === 'teardown') {
retryQueue.delete(operation.key);
return operation;
} else if (
operation.context._instance &&
bypassQueue.has(operation.context._instance)
) {
Expand All @@ -346,7 +339,7 @@ export function authExchange(
filter(Boolean)
) as Source<Operation>;

const result$ = pipe(merge([opsWithAuth$, teardownOps$]), forward);
const result$ = pipe(opsWithAuth$, forward);

return pipe(
result$,
Expand Down

0 comments on commit 9bf5583

Please sign in to comment.