BUG: JS interop au rendu statique — 'cannot be issued at this time' après F5 (auth) #42

Closed
opened 2026-08-10 22:35:18 +02:00 by nonobis · 1 comment
Owner

Contexte

Après connexion puis rechargement complet (F5) d'une page authentifiée, l'UI affiche : "Erreur : JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered."

État actuel

  • Le fix db703be (prerender:false sur Routes) ne suffit pas.
  • Pendant le rendu initial serveur, HeimdallAuthStateProvider.GetAuthenticationStateAsync() invoqué par le framework : ProtectedSessionStorage.GetAsync() lève une exception non attrapée qui remonte jusqu'aux pages (Snackbar "Erreur : {ex.Message}").

Correctif appliqué

  • Garde dans GetAuthenticationStateAsync / NotifyLoginAsync / NotifyLogoutAsync : ProtectedSessionStorage (JS interop) n'est utilisé que si HttpContext est null (circuit actif) ; sinon fallback cookie uniquement.
  • Tests bUnit de régression : StaticRender_WithStorageThatThrows_FallsBackToCookieWithoutJsInterop + NotifyLoginAsync_StaticRender_DoesNotCallStorageButUpdatesState.
  • Vérifié en réel : F5 sur /dashboard ne déclenche plus l'erreur JS interop.

Reste

  • Au premier rendu après F5, les appels API des pages (ex. /api/stats) renvoient 401 tant que le circuit n'a pas peuplé AuthState depuis sessionStorage — problème distinct (cf. kanban BUG: UI Blazor appelle l'API en HTTP interne).
## Contexte Après connexion puis rechargement complet (F5) d'une page authentifiée, l'UI affiche : "Erreur : JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered." ## État actuel - Le fix db703be (prerender:false sur Routes) ne suffit pas. - Pendant le rendu initial serveur, HeimdallAuthStateProvider.GetAuthenticationStateAsync() invoqué par le framework : ProtectedSessionStorage.GetAsync() lève une exception non attrapée qui remonte jusqu'aux pages (Snackbar "Erreur : {ex.Message}"). ## Correctif appliqué - Garde dans GetAuthenticationStateAsync / NotifyLoginAsync / NotifyLogoutAsync : ProtectedSessionStorage (JS interop) n'est utilisé que si HttpContext est null (circuit actif) ; sinon fallback cookie uniquement. - Tests bUnit de régression : StaticRender_WithStorageThatThrows_FallsBackToCookieWithoutJsInterop + NotifyLoginAsync_StaticRender_DoesNotCallStorageButUpdatesState. - Vérifié en réel : F5 sur /dashboard ne déclenche plus l'erreur JS interop. ## Reste - Au premier rendu après F5, les appels API des pages (ex. /api/stats) renvoient 401 tant que le circuit n'a pas peuplé AuthState depuis sessionStorage — problème distinct (cf. kanban BUG: UI Blazor appelle l'API en HTTP interne).
Author
Owner

Implémenté, build + tests Web verts (167), poussé. Commit: 3b3e74d (#32) / ce05faf (#42). Vérifié en réel.

Implémenté, build + tests Web verts (167), poussé. Commit: 3b3e74d (#32) / ce05faf (#42). Vérifié en réel.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nonobis/Heimdall#42
No description provided.