Skip to content

Commit

Permalink
fix: don't set signal on fetch unless provided to client.fetch (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Aug 17, 2023
1 parent 7f64b79 commit e1d5210
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
},
"dependencies": {
"@sanity/eventsource": "^5.0.0",
"get-it": "^8.4.2",
"get-it": "^8.4.3",
"rxjs": "^7.0.0"
},
"devDependencies": {
Expand Down
8 changes: 7 additions & 1 deletion src/data/dataMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export function _fetch<R, Q extends QueryParams>(
): Observable<RawQueryResponse<R> | R> {
const mapResponse =
options.filterResponse === false ? (res: Any) => res : (res: Any) => res.result
const {cache, next, ...opts} = options
const {cache, next, ...opts} = {
// Opt out of setting a `signal` on an internal `fetch` if one isn't provided.
// This is necessary in React Server Components to avoid opting out of Request Memoization.
useAbortSignal: typeof options.signal !== 'undefined',
...options,
}
const reqOpts =
typeof cache !== 'undefined' || typeof next !== 'undefined'
? {...opts, fetch: {cache, next}}
Expand Down Expand Up @@ -235,6 +240,7 @@ export function _dataRequest(
canUseCdn: isQuery,
signal: options.signal,
fetch: options.fetch,
useAbortSignal: options.useAbortSignal,
}

return _requestObservable(client, httpRequest, reqOptions).pipe(
Expand Down

0 comments on commit e1d5210

Please sign in to comment.