fix: support async Svelte #9810
main fromrefs/pull/9810/head·merged by lachlancollins View on GitHubShowing 2 changed files with 32 additions and 5 deletions.
Thanks for tackling async Svelte lifecycles! A few technical considerations on this implementation:
SSR Subscription Teardown: Because
typeof window === 'undefined'evaluates to false on the server,observer.subscribe(...)will run eagerly during SSR. Given thetry...catcharoundonDestroy, if this runs in streaming SSR or an edge context whereonDestroylifecycle guarantees differ, could this risk leaking query subscriptions in long-running Node processes?Immediate Redundant Resubscription: The eager
observer.subscribe()at initialization is immediately followed bywatchChanges(..., 'pre'), which runs its setup phase and immediately tears down (unsubscribe()) and recreates the subscription. Could the eager call be integrated cleanly into the watcher to prevent churn on initial component mount?Regression Test Coverage: Because this touches tricky boundaries between eager SSR subscription,
$effect.pre, and uncompleted async component teardown, adding a regression test inpackages/svelte-query/tests(simulating an unmount before async resolution) would be invaluable to safeguard against future Svelte compiler updates.