Skip to content

Commit

Permalink
πŸ› (fix): stop useStream from opening streams when disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nickadamson committed Dec 28, 2023
1 parent a06811f commit d93279c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/hooks/useStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ export const useStream = <
...queryOptions,
queryKey,
queryFn: async () => {
if (queryOptions.enabled === false) {
// If the query is disabled, early return empty response
return {
done: true,
responses: [],
};
}

let responses: O[] = [];
const streamId = streamIdRef.current;
streamIdRef.current += 1;
Expand Down

0 comments on commit d93279c

Please sign in to comment.