fix(convex): prevent OOM by filtering large inventory fields
- Add INVENTORY_BLOCKLIST to filter 'software' and 'extended' fields from machine metadata (these fields can be 100KB+ each) - Add compactMachineMetadata migration to clean existing large documents - Preserve essential fields: metrics, postureAlerts, collaborator, inventory.os, cpu, memory, disks, network, services 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
508f915cf9
commit
cf28ad2ee4
2 changed files with 122 additions and 0 deletions
|
|
@ -251,6 +251,10 @@ function isObject(value: unknown): value is Record<string, unknown> {
|
|||
return Boolean(value) && typeof value === "object" && !Array.isArray(value)
|
||||
}
|
||||
|
||||
// Campos do inventory que sao muito grandes e nao devem ser persistidos
|
||||
// para evitar OOM no Convex (documentos de ~100KB cada)
|
||||
const INVENTORY_BLOCKLIST = new Set(["software", "extended"])
|
||||
|
||||
function mergeInventory(current: unknown, patch: unknown): unknown {
|
||||
if (!isObject(patch)) {
|
||||
return patch
|
||||
|
|
@ -258,6 +262,8 @@ function mergeInventory(current: unknown, patch: unknown): unknown {
|
|||
const base: Record<string, unknown> = isObject(current) ? { ...(current as Record<string, unknown>) } : {}
|
||||
for (const [key, value] of Object.entries(patch)) {
|
||||
if (value === undefined) continue
|
||||
// Filtrar campos volumosos que causam OOM
|
||||
if (INVENTORY_BLOCKLIST.has(key)) continue
|
||||
if (isObject(value) && isObject(base[key])) {
|
||||
base[key] = mergeInventory(base[key], value)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue