BUG: onSuccess in useMutationFeedback triggers repeated executions / infinite re-render loop
Los mantenedores suelen responder en 10 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- react, redux, typescript
- Área
- frontend
Línea de trabajo
Lee frontend/src/hooks/useMutationFeedback.tsx y el uso de useFolderOperations.tsx en la ubicación indicada para entender el comportamiento del callback y del efecto. Comprueba cómo el hook gestiona las notificaciones de error y cómo sus pruebas cubren las transiciones de éxito. La tarea estará terminada cuando el callback de éxito se ejecute y el diálogo se muestre una sola vez por cada transición de éxito, incluso si hay nuevos renderizados o cambia la referencia del callback.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Is there an existing issue for this?
- I have searched the existing issues
What happened?
In frontend/src/hooks/useMutationFeedback.tsx, the success state handler is implemented as:
// Handle success state
useEffect(() => {
if (isSuccess && showSuccess) {
dispatch(
showInfoDialog({
title: successTitle,
message: successMessage,
variant: 'info',
}),
);
if (onSuccess) {
onSuccess();
}
}
}, [
isSuccess,
showSuccess,
successTitle,
successMessage,
dispatch,
onSuccess,
]);
The Problem & Root Cause:
onSuccessis included in theuseEffectdependency array.- In typical consumer usage (such as in
useFolderOperations.tsx), options containingonSuccessare passed as an inline object:useMutationFeedback( { ...foldersQuery }, { loadingMessage: 'Loading folders', showSuccess: false, onSuccess: () => { const folders = foldersQuery.data?.data?.folders as FolderDetails[]; dispatch(setFolders(folders)); }, }, ); - On every re-render of the component or custom hook, a new inline function reference is created for
onSuccess. - TanStack Query retains
isSuccess: truefor the duration of the query/mutation cache. - Because
onSuccesschanges reference on every render whileisSuccessis stilltrue,useEffectre-executes on every single render:- If
showSuccessis enabled,dispatch(showInfoDialog(...))will be dispatched again on every re-render. onSuccess()will be invoked again, which typically dispatches an update to the Redux store or sets local state.- That state update triggers another component re-render, creating a new
onSuccessfunction reference, which retriggersuseEffect— resulting in an infinite render/dispatch loop or redundant Redux state updates.
- If
Unlike the error handler which uses lastShownErrorMsg to prevent spam, the success handler has no execution guard.
Expected Behavior:
onSuccessandshowInfoDialogshould execute exactly once per success transition (whenisSuccesstransitions fromfalsetotrue).- Re-renders or reference changes to inline
onSuccessfunctions whileisSuccessremainstrueshould not re-triggeronSuccessor re-open the success dialog.
Steps to Reproduce:
- Call
useMutationFeedbackwith an inlineonSuccesscallback that updates state or dispatches to Redux (as seen inuseFolderOperations). - Trigger the query or mutation until it succeeds (
isSuccess = true). - Observe
onSuccessexecuting repeatedly on every re-render whileisSuccessremainstrue.
Record
- I agree to follow this project's Code of Conduct
- Lenguaje dominante
- Python
- Estrellas
- 320
- Forks
- 771
- Merge medio
- 9 d 5 h
- PR fusionados (30 d)
- 15
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de AOSSIE-Org/PictoPy
-
BUG: Add images to album: success message shows requested count, not number actually addedPosiblemente ocupada @avika269 la tomó hace 3 días. Abiertobug enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
AOSSIE-Org/PictoPy#1740 · 2 comentarios ·
Los mantenedores suelen responder en 10 días
-
BUG: /sync-folder does not validate the supplied folder_idPosiblemente ocupada @sathvikn113 la tomó hace 4 días. Abiertobug possible-duplicate
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
AOSSIE-Org/PictoPy#1731 · 5 comentarios ·
Los mantenedores suelen responder en 10 días
-
DOC: update deprecated libgl1-mesa-glx package and stale setup.md referencesPosiblemente ocupada @avika269 la tomó hace 4 días. Abiertodocumentation
Dificultad 1/5 1-3 horas Aptitud para principiantes 65/100
AOSSIE-Org/PictoPy#1730 · 5 comentarios ·
Los mantenedores suelen responder en 10 días
-
BUG: Memory curator misses upcoming anniversaries across year boundaries and on leap daysPosiblemente ocupada @akhilmodi29 la tomó hace 5 días. Abiertobug possible-duplicate
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
AOSSIE-Org/PictoPy#1725 · 4 comentarios ·
Los mantenedores suelen responder en 10 días
-
BUG: Album create/update accept a blank or whitespace-only namePosiblemente ocupada @sayxnn17 la tomó hace 3 días. Abiertobug possible-duplicate
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
AOSSIE-Org/PictoPy#1722 · 5 comentarios ·
Los mantenedores suelen responder en 10 días
Todos los issues de AOSSIE-Org/PictoPy
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
needs-format
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Niko1221/Strata#6475 · 1 comentario ·
Los mantenedores suelen responder en 6 días
-
skills: _skill_body cuts the frontmatter short when a description contains ---Posiblemente ocupada @nurlanmnn la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
zilliztech/memsearch#876 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
acl-org/acl-anthology#11025 ·
Los mantenedores suelen responder en 1 día