Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/queryCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export function makeQueryCache({ frozen = isServer, defaultConfig } = {}) {

let [queryKey, config, { force, throwOnError } = {}] = getQueryArgs(args)

// https://github.com/tannerlinsley/react-query/issues/652
config = { retry: false, ...config }

try {
const query = queryCache.buildQuery(queryKey, config)
if (force || query.state.isStale) {
Expand Down
14 changes: 14 additions & 0 deletions src/core/tests/queryCache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ describe('queryCache', () => {
).not.toThrow()
})

// https://github.com/tannerlinsley/react-query/issues/652
test('prefetchQuery should not retry by default', async () => {
await expect(
queryCache.prefetchQuery(
'key',
async () => {
throw new Error('error')
},
{},
{ throwOnError: true }
)
).rejects.toEqual(new Error('error'))
})

test('prefetchQuery returns the cached data on cache hits', async () => {
const fetchFn = () => Promise.resolve('data')
const first = await queryCache.prefetchQuery('key', fetchFn)
Expand Down