Skip to content

fix(perf): bound sharp screenshot memory in hosted mode to prevent pod OOM - #454

Merged
gaurav-singh-9227 merged 2 commits into
browserstack:mainfrom
SavioBS629:fix/screenshot-sharp-memory
Sep 30, 2026
Merged

gaurav-singh-9227 merged 2 commits into
browserstack:mainfrom
SavioBS629:fix/screenshot-sharp-memory

Conversation

@SavioBS629

Copy link
Copy Markdown
Collaborator

What & why

fetchAutomationScreenshots decodes/compresses up to 5 session screenshots
concurrently (Promise.all) through sharp, and sharp was never
configured — so it ran with its default libvips cache and a thread pool
sized to CPU cores. Several tens-of-MB pixel buffers decoded at once, with
no cap on peak memory, is a real OOM risk on memory-constrained hosted pods
(a few concurrent calls can exceed the pod's headroom).

Change (scoped to hosted REMOTE_MCP mode; local unchanged)

  • sharp.cache(false) + sharp.concurrency(1) — no libvips cache, single
    worker thread — when running hosted.
  • Process screenshots sequentially when hosted, so peak memory is a single
    image rather than all of them at once.
  • Local (npx) behaviour is unchanged — still the concurrent path with
    sharp defaults (local machines aren't memory-constrained).

Test

  • tsc, eslint: clean
  • Full suite: 72 files / 1118 tests pass
  • tests/setup.ts sharp mock extended with cache/concurrency no-ops

🤖 Generated with Claude Code

SavioBS629 and others added 2 commits September 29, 2026 18:26
… OOM

fetchAutomationScreenshots compressed up to 5 screenshots concurrently
(Promise.all) through sharp, with sharp's default libvips cache and a
thread pool sized to CPU cores and no cap on peak buffers. On memory-
constrained pods that is an OOM risk (several tens-of-MB pixel buffers
decoded at once).

- Configure sharp once: cache(false) + concurrency(1) — no libvips cache,
  single worker thread.
- Process screenshots sequentially so peak memory is a single image rather
  than all of them at once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…d OOM

fetchAutomationScreenshots compressed up to 5 screenshots concurrently
(Promise.all) through sharp, with sharp's default libvips cache and a
CPU-core-sized thread pool. On memory-constrained hosted pods that peak
(several tens-of-MB pixel buffers decoded at once) is an OOM risk.

Scoped to hosted (REMOTE_MCP) mode only — local runs are unchanged:
- sharp cache(false) + concurrency(1) when REMOTE_MCP.
- Screenshots processed sequentially when REMOTE_MCP (peak = one image);
  local keeps the concurrent path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 202b0be9-10ce-49f2-ba91-a46a28c3e657

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@gaurav-singh-9227
gaurav-singh-9227 merged commit 8401de1 into browserstack:main Sep 30, 2026
3 checks passed
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.

3 participants