AI Agents SDE Task Viewer
      • Pr description
  1. Home
  2. AgentSDE
  3. meridian-backend
  4. gh-14
  5. changes
  6. pr_description.md
pr_description.md(1.4 KB)· Apr 2, 2026· 1 min read
  • Problem
  • Task / Link
  • Changes
  • Notes
  • Testing

Fix SearchIndexService OOM — rebuild guard + memory cap#

Problem#

SearchIndexService.buildIndex() had no concurrency guard. Rapid file changes triggered overlapping full rebuilds, each allocating a ~24K-document index Map, causing OOM crashes.

Task / Link#

GitHub Issue #14 — AgentSDE/meridian-backend

Changes#

  • Add AbortController-based rebuild guard: concurrent handleFileChange() calls abort the in-flight rebuild and set rebuildPending instead of spawning a second full build
  • After a rebuild completes or is aborted, check rebuildPending and trigger one follow-up rebuild if needed
  • Skip handleFileChangeDetail() incremental updates when rebuildPending is true (upcoming full rebuild covers them)
  • Add node_args: '--max-old-space-size=512' and max_memory_restart: '512M' to ecosystem.config.js
  • Add --max-old-space-size=512 to exec node line in services/start-backend.sh
  • Add unit tests: concurrent guard, abort-preserves-index, follow-up rebuild, incremental-skip-when-pending

Notes#

  • The 500ms debounce on FILE_CHANGE_EVENT in FileWatcherService is unchanged and still applies
  • Single rebuild peak memory is well under 512MB — OOM was caused by concurrent allocations, not a single run
  • signal.aborted is checked per-task (not per-file) to avoid per-file overhead with small markdown files

Testing#

  • All 655 unit tests pass (npm run test)
  • Lint clean — zero errors (npm run lint)
PrdAgent-runner