From 557e3ed8e0982455b51cbde1e57384d239a4a180 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Thu, 2 Apr 2026 16:55:46 +0200 Subject: [PATCH] feat: implement server-side data loader for product grid rows with caching and aggregation logic --- src/features/grid/api/get-product-rows.ts | 26 ++++------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/features/grid/api/get-product-rows.ts b/src/features/grid/api/get-product-rows.ts index 262dc99..d4522ba 100644 --- a/src/features/grid/api/get-product-rows.ts +++ b/src/features/grid/api/get-product-rows.ts @@ -16,7 +16,6 @@ import { import { db } from "@/db"; import { sessionSnapshots } from "@/db/schema"; import { eq, desc } from "drizzle-orm"; -import { unstable_cache } from "next/cache"; // ─── Tag de cache par fournisseur ───────────────────────────────────────────── // Permet d'invalider précisément le cache d'un seul fournisseur lors d'une sauvegarde. @@ -315,31 +314,14 @@ async function _fetchAllProductRows(codeFournisseur: string): Promise { const { codeFournisseur } = input; - - // Créer dynamiquement la fonction cachée avec le tag spécifique au fournisseur. - // unstable_cache mémoïse par le tableau de clés [`grid-rows-${codeFournisseur}`]. - const cachedFn = unstable_cache( - async () => _fetchAllProductRows(codeFournisseur), - [`grid-rows-${codeFournisseur}`], - { revalidate: 300, tags: [`grid-rows-${codeFournisseur}`] } - ); - - try { - return await cachedFn(); - } catch (e) { - console.error(`[getProductRows] Cache error for ${codeFournisseur}:`, e); - // Fallback sans cache si unstable_cache échoue - return _fetchAllProductRows(codeFournisseur); - } + + // Appel direct sans l'enveloppe dynamique de unstable_cache qui cause un freeze/timeout + return _fetchAllProductRows(codeFournisseur); }