Skip to content

fix: memory leak in translation execution (unbounded Map growth) #1547

@NiranjanKumar001

Description

@NiranjanKumar001

What

Memory leak in packages/cli/src/cli/cmd/run/execute.ts where the perFileIoLimiters Map grows indefinitely and is never cleared, causing unbounded memory accumulation across multiple translation runs.

Current behavior:

  • Map uses lazy allocation: creates limiters on-demand when first accessed (lines 58-68)
  • Map entries are never removed or cleared after task completion
  • In watch mode or long-running processes, memory grows indefinitely
  • Each unique bucket pattern adds a new Map entry that persists in memory

Expected behavior:

  • Map should have fixed size based on number of unique bucket patterns
  • Memory should be released after task completion
  • No memory accumulation across multiple runs

Location: packages/cli/src/cli/cmd/run/execute.ts, lines 58-68

Current code:

const perFileIoLimiters = new Map<string, LimitFunction>();
const getFileIoLimiter = (bucketPathPattern: string): LimitFunction => {
  const lockKey = bucketPathPattern;
  if (!perFileIoLimiters.has(lockKey)) {
    perFileIoLimiters.set(lockKey, pLimit(1)); // ❌ Unbounded growth
  }
  return perFileIoLimiters.get(lockKey)!;
};


please assign this to me 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions