-
Notifications
You must be signed in to change notification settings - Fork 472
Closed
Labels
bug 🐛Oh no! A bug or unintented behaviour.Oh no! A bug or unintented behaviour.needs more info ✋A question or report that needs more info to be addressableA question or report that needs more info to be addressable
Description
💀 I just discovered something that ruined my day! 💀
😢 😄 😢 😄 😢
REPL: https://codesandbox.io/s/urql-svelte-crud-pollinterval-keeps-calling-ohr25
I thought that all queries in my components were "destroyed" when every single component was "destroyed".
But perhaps it's not!
I'm using svelte
package.
As you can see from REPL in Todo.svelte file:
<script>
import { onDestroy } from "svelte";
import { push } from "svelte-spa-router";
import { query, mutate } from "@urql/svelte";
import { TODO_QUERY, UPDATE_TODO } from "./gql";
export let params;
function updateTodo(id) {
mutate({ query: UPDATE_TODO, variables: { id } });
push("#/todos");
}
$: todo = query({
query: TODO_QUERY,
variables: { id: params.id },
requestPolicy: "cache-and-network",
pollInterval: 2000
});
onDestroy(() => console.log("I'm destroying myself!"));
</script>
<h3>Todo detail view</h3>
<br>
{#if !$todo || $todo.fetching || !$todo.data}
Loading todo...
{:else if $todo.error}
Oh no! {$todo.error.message}
{:else}
<b>ID</b>: {$todo.data.todo.id}<br><br>
<b>Text</b>: {$todo.data.todo.text}<br><br>
<b>Complete</b>: {$todo.data.todo.complete}<br><br>
<button on:click={() => updateTodo($todo.data.todo.id)}>{$todo.data.todo.complete}</button>
{/if}
I'm using
pollInterval: 2000
and I have this:
onDestroy(() => console.log("I'm destroying myself!"));
but just after that console.log("")
appears in browser's console the urql polling
continues indefinitely!!! 💀 💀 💀
WHY???
Metadata
Metadata
Assignees
Labels
bug 🐛Oh no! A bug or unintented behaviour.Oh no! A bug or unintented behaviour.needs more info ✋A question or report that needs more info to be addressableA question or report that needs more info to be addressable