I have this confusing issue with svelte-query 1.6.0, @sveltejs/kit 1.0.0-next.295, and svelte 3.46.4.
Occasionally, svelte-query will seemingly at random run the query server-side, and returns an empty result with 'success' status.
This query usually works, and if this error happens, I can just open the URL in a new tab and it works fine.
Error:
500
Cannot read property 'muxVideo' of null
TypeError: Cannot read property 'muxVideo' of null
at [slug].svelte:98:63
at Object.$$render (/Users/ben/dev/my-project/node_modules/svelte/internal/index.js:1745:22)
at Object.default (root.svelte:50:47)
at Object.default (/src/routes/__layout.svelte:187:36)
at eval (/node_modules/@sveltestack/svelte-query/svelte/queryClientProvider/QueryClientProvider.svelte:38:41)
at Object.$$render (/Users/ben/dev/my-project/node_modules/svelte/internal/index.js:1745:22)
at __layout.svelte:106:29
at Object.$$render (/Users/ben/dev/my-project/node_modules/svelte/internal/index.js:1745:22)
at root.svelte:38:45
at $$render (/Users/ben/dev/my-project/node_modules/svelte/internal/index.js:1745:22)
If I log the query result, I get this in the backend logs:
<script>
const graphQLClientStore = writable(graphQLClient);
fetchToken();
setContext('graphql-client', graphQLClientStore);
async function fetchToken() {
// XXX: Temp workaround due to:
// https://github.com/sveltejs/kit/issues/1198
//
// Also see:
// https://github.com/sveltejs/kit/issues/696
// https://github.com/sveltejs/kit/issues/672
//
// Until this is resolved, useQueryClient cannot
// be used because we need to reactively update
// the client with the token after the app has
// initialised. useQueryClient doesn't allow this
const userAuth = await fetch('/api/auth/user');
const tokens = await userAuth.json();
const jwt = tokens.jwt;
$graphQLClientStore.setFetchOptions({
headers: {
'X-Auth-Token': jwt
}
});
// Trigger reactive update
$graphQLClientStore = $graphQLClientStore;
}
onMount(async () => {
fetchToken();
});
</script>
I have this confusing issue with
svelte-query
1.6.0,@sveltejs/kit
1.0.0-next.295, andsvelte
3.46.4.Occasionally,
svelte-query
will seemingly at random run the query server-side, and returns an empty result with 'success' status.This query usually works, and if this error happens, I can just open the URL in a new tab and it works fine.
Error:
If I log the query result, I get this in the backend logs:
My component:
__layout.svelte
: