-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[RED-10] prefetch
creates a suscription that can not be unsubscribed
#1283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are there ideas for how Running Edit: I've reviewed the source more and now understand this isn't a relevant question. Nothing is returned now, so the change would not be breaking |
…ribes if not present [reduxjs#1283]
In PR #1938 I toyed around with prefetch resolving void OR the query result, exposing |
The next approach will be to provide a config option like |
…mer reduxjs#1283 Closes reduxjs#1283 Automatically removes prefetch subscriptions after configurable amount of time. Description: Prefetch subscription are now removed after `prefetchOptions.keepSubscriptionFor` if provided or api.config.keepPrefetchSubscriptionsFor otherwise. Api changes: - adds `keepSubscriptionFor` to prefetchOptions - adds `keepPrefetchSubscriptionsFor` to api.config (default 10s) Internal changes: - prefetch queries now have the same requestId and the same subscription key
…mer reduxjs#1283 Closes reduxjs#1283 Automatically removes prefetch subscriptions after configurable amount of time. Description: Prefetch subscription are now removed after `prefetchOptions.keepSubscriptionFor` if provided or api.config.keepPrefetchSubscriptionsFor otherwise. Api changes: - adds `keepSubscriptionFor` to prefetchOptions - adds `keepPrefetchSubscriptionsFor` to api.config (default 10s) Internal changes: - prefetch queries now have the same requestId and the same subscription key
Description: prefetch thunk now returns an object with shape: ```ts export interface PrefetchActionCreatorResult { /** * Returns a promise that **always** resolves to `undefined` * when there are no pending requests initiated by input thunk. */ unwrap(): Promise<void>, /** * Cancels pending requests. */ abort(): void } ```
…mer reduxjs#1283 Closes reduxjs#1283 Automatically removes prefetch subscriptions after configurable amount of time. Description: Prefetch subscription are now removed after `prefetchOptions.keepSubscriptionFor` if provided or api.config.keepPrefetchSubscriptionsFor otherwise. Api changes: - adds `keepSubscriptionFor` to prefetchOptions - adds `keepPrefetchSubscriptionsFor` to api.config (default 10s) Internal changes: - prefetch queries now have the same requestId and the same subscription key
Description: prefetch thunk now returns an object with shape: ```ts export interface PrefetchActionCreatorResult { /** * Returns a promise that **always** resolves to `undefined` * when there are no pending requests initiated by input thunk. */ unwrap(): Promise<void>, /** * Cancels pending requests. */ abort(): void } ```
@phryneas Bumping this since it can really lead to unpredictable behavior in the app. In general, subscription management is not straightforward. |
@vladamx could you clarify what you mean by "subscription management is not straightforward" ? |
@markerikson I mainly meant that hanging or global subscriptions are not easy to find just by statically reading the code. Those subscriptions cause data to never update regardless of keepUnusedFor. Devtools help to spot their count but does not pinpoint where are those subs. |
@markerikson This literally just introduce a bug in our app where the cache wouldn't clean up because of that dangling subscription. However, I think the unsubscription should happen automatically. |
@dorsharonfuse honestly, we're pretty busy with a lot of other things right now. We'll happily accept PRs that fix an issue like this, but this is not a priority for us maintainers to work on atm. |
prefetch
creates a suscription that can not be unsubscribedprefetch
creates a suscription that can not be unsubscribed
This is still a thing we'd like to improve, but we're going to focus 2.0 on the existing packaging changes, and defer pretty much all RTKQ changes to a follow-up release (including a likely RTK 3.0 in the semi-near future that would contain any actual breaking changes to RTKQ's API). Still happy to accept a PR that improves this! |
we still waiting for this feature! It would be great. Thanks |
this is still present, right? |
We haven't had time yet this year to do any further work on RTKQ, so no changes yet. |
Could you indicate in the documentation that unsubscribing from prefetch is not working at the moment? |
I just ran into this issue as well. I used |
Currently,
prefetch
creates a subscription that cannot be unsubscribed.Ideally,
prefetch
should eitherIt could also just take an option to switch between those two behaviours.
RED-10
The text was updated successfully, but these errors were encountered: