invoke-ai / InvokeAI

InvokeAI is a leading creative engine for Stable Diffusion models, empowering professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry leading WebUI, supports terminal use through a CLI, and serves as the foundation for multiple commercial products.
https://invoke-ai.github.io/InvokeAI/
Apache License 2.0
23.17k stars 2.4k forks source link

[bug]: unsubscribe from RTK Query queries correctly #3999

Open psychedelicious opened 1 year ago

psychedelicious commented 1 year ago

Is there an existing issue for this?

OS

Linux

GPU

cuda

VRAM

No response

What version did you experience this issue on?

main

What happened?

We are manually kicking off RTK Query queries in a number of places, like invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketConnected.ts:

dispatch(modelsApi.endpoints.getMainModels.initiate(REFINER_BASE_MODELS));

This creates a subscription for that data - and we aren't cleaning up after ourselves. What we need to do is this:

const result = dispatch(
  modelsApi.endpoints.getMainModels.initiate(REFINER_BASE_MODELS)
);
result.unsubscribe();

This only needs to happen for queries, not mutations.

If we relied on cache subscriptions expiring, this would cause issues. We don't now, so this is mainly just sloppy and inefficient, rather than major issue.

Screenshots

No response

Additional context

No response

Contact Details

No response

amitduaaa commented 1 year ago

I would like to work on this issue.

Millu commented 1 year ago

@iconichal that's awesome! Let us know if there's anything you have questions on - happy to help support however we can

psychedelicious commented 1 year ago

@iconichal I did fix a few of these - but very happy for you to update any others!