Issue #8469 - fix(solid-query): client() doesn't return undefined#8992
Closed
gopnik5 wants to merge 0 commit intoTanStack:mainfrom
gopnik5:main
Closed
Issue #8469 - fix(solid-query): client() doesn't return undefined#8992gopnik5 wants to merge 0 commit intoTanStack:mainfrom gopnik5:main
gopnik5 wants to merge 0 commit intoTanStack:mainfrom
gopnik5:main
Conversation
|
Thank you very much for taking a look into this @gopnik5! I cannot make a statement about the implementation of the fix, but a test I wrote locally for the issue indeed passes now. Maybe it is useful to you as template for a regression test (in // ...
// I only managed to reproduce the issue with @solidjs/router, so I had to add it to devDependencies
import { Route, MemoryRouter, createMemoryHistory } from '@solidjs/router'
describe('useQuery', () => {
// ...
it('should not reproduce issue #8469', async () => {
const queryCache = new QueryCache()
const queryClient = new QueryClient({ queryCache });
const history = createMemoryHistory();
const errorHandler = vi
.fn<(err: unknown) => void>()
function App() {
return (
<ErrorBoundary
fallback={(err) => {
errorHandler(err)
return err.message
}}
>
<Suspense>
<MemoryRouter history={history}>
<Route path="/" component={Index} />
<Route path="/sub" component={Sub} />
</MemoryRouter>
</Suspense>
</ErrorBoundary>
)
}
queryClient.setQueryData(['parent'], { id: 123})
function Index() {
return 'Index'
}
function Sub() {
const parent = useQuery(() => ({
queryKey: ['parent'],
async queryFn() {
await new Promise((r) => setTimeout(r, 100))
return {
id: 123,
}
},
// refetchOnMount: false, // this would remove the error
}))
const childQuery = useQuery(() => ({
queryKey: ['sub', parent.data?.id],
// enabled: parent.data?.id != null,
async queryFn() {
await new Promise((r) => setTimeout(r, 200))
return Promise.resolve('child' + parent.data?.id)
},
}))
return <pre>{childQuery.data}</pre>
}
const rendered = render(() => (
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
))
await waitFor(() => rendered.getByText('Index'))
// Navigate to the sub page to trigger the error
history.set({
value: '/sub',
})
// Wait for the error to occur
await sleep(200)
expect(errorHandler).not.toHaveBeenCalled()
await waitFor(() => {
expect(rendered.getByText('child123')).toBeInTheDocument()
})
})
}) |
Contributor
Author
|
Thank you! I'll take a look. |
|
View your CI Pipeline Execution ↗ for commit 24d451f. ☁️ Nx Cloud last updated this comment at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #8469 - fix(solid-query): client() doesn't return undefined