Skip to content

Conversation

@sigfawn
Copy link

@sigfawn sigfawn commented Jan 2, 2026

This PR prevents memory exhaustion (OOM) when querying large audit logs.

1. Stream-based File Reading

  • Problem: The queryLogs method was using fs.readFile to load the entire log file content into memory at once. For large log files (100MB+), this allocated massive strings on the heap, causing OOM crashes or severe GC pauses.
  • Fix: Replaced fs.readFile with fs.createReadStream and readline.createInterface. This processes the file line-by-line, maintaining a constant O(1) memory footprint regardless of file size.

Result: Scalable log querying that is safe for production use with large log rotation policies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant