mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 05:34:58 -05:00
docs(ui): add some comments for race condition handling
This commit is contained in:
@@ -29,6 +29,8 @@ export const ImageViewerContextProvider = memo((props: PropsWithChildren) => {
|
||||
const $progressEvent = useState(() => atom<S['InvocationProgressEvent'] | null>(null))[0];
|
||||
const $progressImage = useState(() => atom<ProgressImageType | null>(null))[0];
|
||||
const $hasProgressImage = useState(() => computed($progressImage, (progressImage) => progressImage !== null))[0];
|
||||
// We can have race conditions where we receive a progress event for a queue item that has already finished. Easiest
|
||||
// way to handle this is to keep track of finished queue items in a cache and ignore progress events for those.
|
||||
const [finishedQueueItemIds] = useState(() => new LRUCache<number, boolean>({ max: 200 }));
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -46,6 +46,8 @@ const selectModelInstalls = modelsApi.endpoints.listModelInstalls.select();
|
||||
export const setEventListeners = ({ socket, store, setIsConnected }: SetEventListenersArg) => {
|
||||
const { dispatch, getState } = store;
|
||||
|
||||
// We can have race conditions where we receive a progress event for a queue item that has already finished. Easiest
|
||||
// way to handle this is to keep track of finished queue items in a cache and ignore progress events for those.
|
||||
const finishedQueueItemIds = new LRUCache<number, boolean>({ max: 100 });
|
||||
|
||||
socket.on('connect', () => {
|
||||
|
||||
Reference in New Issue
Block a user