Skip to content

fix(memory): restart Chromium when over the memory budget - #43

Merged
HarshMN2345 merged 5 commits into
mainfrom
fix-restart-chromium-over-budget
Nov 25, 2026
Merged

HarshMN2345 merged 5 commits into
mainfrom
fix-restart-chromium-over-budget

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

What changed

  • The memory guard restarts Chromium when the container crosses the budget, instead of closing the newest capture. In-flight captures fail with 507 and Chromium relaunches immediately.
  • Screenshot and report routes ignore context close errors after Chromium is gone, so those captures return 507 instead of 500.
  • The memory recovery test expects the new message and waits for health to return 200 after the relaunch.

Closing pages did not free memory: on fra1 a pod logged "Memory budget exceeded" 1,770 times over a week at ~1.75 of 2 GiB before it was OOM-killed.

Tested

  • bun run lint, bun run check, bun run type-check
  • bun test tests/unit
  • bun test tests/recovery against a locally built appwrite/browser:local

Closing the newest capture never handed memory back: a long-lived
Chromium stayed over budget for days until the container was OOM-killed.
@appwrite

appwrite Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
e7301c4 Reviewed Reviewed 🟢 S · Ready to merge ✅ Approved View review

No actionable issues remain; the previously reported documentation and restart-verification gaps are addressed.

The memory guard now restarts shared Chromium when container memory exceeds the configured budget, causing in-flight screenshot and report captures to fail with 507. Route cleanup tolerates browser shutdown, and the README and recovery test describe and check the restart behavior.

Latest changes: The newest commits update the README to describe Chromium restarts and add a recovery-test assertion for the relaunch log.

Walkthrough (5)
File Change
README.md Documents that exceeding the memory budget restarts Chromium and fails in-flight captures with 507.
src/routes/reports.ts Ignores context-close errors when Chromium shuts down during a report capture.
src/routes/screenshots.ts Ignores context-close errors when Chromium shuts down during a screenshot capture.
src/utils/memory.ts Restarts Chromium and marks tracked captures exceeded when memory crosses the configured budget.
tests/recovery/memory.test.ts Checks the 507 response, health recovery, memory-budget log, and Chromium relaunch log.
Fixed since the last review (2)
  • Health check does not verify Chromium was restarted · tests/recovery/memory.test.ts:56
  • README still describes the old memory recovery behavior · src/utils/memory.ts:7

Reviewed the commits since eef86ba

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

Comment thread tests/recovery/memory.test.ts Resolved
Comment thread src/utils/memory.ts Resolved

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Docker Image Stats

Metric Value
Image Size 868MB
Memory Usage 110MiB
Cold Start Time 1.02s
Screenshot Time 1.43s

Screenshot benchmark: Average of 3 runs on https://appwrite.io

@HarshMN2345
HarshMN2345 merged commit c1f5540 into main Nov 25, 2026
4 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.

1 participant