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 the try...catch around onDestroy, if this runs in streaming SSR or an edge context where onDestroy lifecycle 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 by watchChanges(..., '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 in packages/svelte-query/tests (simulating an unmount before async resolution) would be invaluable to safeguard against future Svelte compiler updates.