diff --git a/bun.lock b/bun.lock index 802f6b0..c0710a0 100644 --- a/bun.lock +++ b/bun.lock @@ -41,7 +41,7 @@ "better-auth": "^1.3.26", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", - "convex": "^1.28.0", + "convex": "^1.29.2", "date-fns": "^4.1.0", "dotenv": "^16.4.5", "lucide-react": "^0.544.0", @@ -1026,7 +1026,7 @@ "convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="], - "convex": ["convex@1.28.0", "", { "dependencies": { "esbuild": "0.25.4", "prettier": "3.6.2" }, "optionalDependencies": { "react": "19.2.0" }, "bin": { "convex": "bin/main.js" } }, "sha512-40FgeJ/LxP9TxnkDDztU/A5gcGTdq1klcTT5mM0Ak+kSlQiDktMpjNX1TfkWLxXaE3lI4qvawKH95v2RiYgFxA=="], + "convex": ["convex@1.29.2", "", { "dependencies": { "esbuild": "0.25.4", "prettier": "^3.0.0" }, "peerDependencies": { "@auth0/auth0-react": "^2.0.1", "@clerk/clerk-react": "^4.12.8 || ^5.0.0", "react": "^18.0.0 || ^19.0.0-0 || ^19.0.0" }, "optionalPeers": ["@auth0/auth0-react", "@clerk/clerk-react", "react"], "bin": { "convex": "bin/main.js" } }, "sha512-9QCj53/zFV+hHZRP8epU41a3NmOkYDdEtpvSPKjAZp6l60NMN+O3fyOX4r5Y6yzPIhsUpJvMH6xB5xwJTLz92A=="], "crelt": ["crelt@1.0.6", "", {}, "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="], diff --git a/convex/reports.ts b/convex/reports.ts index c509c0c..231974f 100644 --- a/convex/reports.ts +++ b/convex/reports.ts @@ -233,7 +233,39 @@ async function paginateTickets( return; } - const page: PaginatedResult = await paginateFn.call(query, { cursor, numItems: pageSize }); + let page: PaginatedResult; + try { + page = await paginateFn.call(query, { cursor, numItems: pageSize }); + } catch (error) { + // Em cenários raros o Convex pode lançar InvalidCursor quando + // o fingerprint da query muda entre páginas. Nesse caso, + // fazemos fallback para uma leitura simples via collect() + // para evitar quebrar o dashboard. + const message = (error as Error | null | undefined)?.message ?? ""; + const isInvalidCursor = + typeof message === "string" && + message.includes("InvalidCursor"); + // Alguns erros de paginação vêm embrulhados em ConvexError com metadados. + const data = (error as any)?.data; + const isPaginationInvalidCursor = + data && typeof data === "object" && data.paginationError === "InvalidCursor"; + + if (isInvalidCursor || isPaginationInvalidCursor) { + const fallbackQuery = buildQuery(); + const collectFn = fallbackQuery.collect; + if (typeof collectFn !== "function") { + throw error; + } + const docs = await collectFn.call(fallbackQuery); + for (const doc of docs) { + await handler(doc); + } + return; + } + + throw error; + } + for (const doc of page.page) { await handler(doc); } diff --git a/next.config.ts b/next.config.ts index b132fec..077f947 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,8 @@ const nextConfig = { experimental: { turbopackFileSystemCacheForDev: true, }, + // Não há necessidade de alterar o webpack aqui; o código do backend Convex + // (convex-backend-main) não faz parte do bundle Next. } export default nextConfig diff --git a/package.json b/package.json index 1e5a8ca..65152f9 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "better-auth": "^1.3.26", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", - "convex": "^1.28.0", + "convex": "^1.29.2", "date-fns": "^4.1.0", "dotenv": "^16.4.5", "lucide-react": "^0.544.0", diff --git a/stack.yml b/stack.yml index f35038b..8a10785 100644 --- a/stack.yml +++ b/stack.yml @@ -65,7 +65,7 @@ services: start_period: 30s convex_backend: - image: ghcr.io/get-convex/convex-backend:latest + image: sistema_convex_backend:1.29.2 stop_grace_period: 10s stop_signal: SIGINT volumes: @@ -90,10 +90,10 @@ services: failure_action: rollback resources: limits: - # Limite conservador para evitar que o backend afete o host inteiro. - memory: "12G" + # Limite de memória elevado para evitar reinícios por OOM (exit code 137) em cargas de relatórios / índices. + memory: "16G" reservations: - memory: "3G" + memory: "4G" restart_policy: condition: any placement: diff --git a/tsconfig.json b/tsconfig.json index 46800c3..cc6d059 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -42,6 +42,7 @@ "exclude": [ "node_modules", "apps/desktop/**", - "nova-calendar-main/**" + "nova-calendar-main/**", + "convex-backend-main/**" ] }