[PR #5460] [CLOSED] fix(collector): always close Puppeteer browser (Chromium zombie leak) #5453

Closed
opened 2026-06-05 15:21:24 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5460
Author: @Alminc91
Created: 4/17/2026
Status: Closed

Base: masterHead: fix/puppeteer-browser-close-leak


📝 Commits (10+)

  • 7f1c57a Enhance temperature control and improve OpenAI API consistency
  • c785058 newest embed state
  • 83d4c8d feat: RBAC enhancements for SaaS billing model v2.2
  • 106433b Merge upstream/master with RBAC enhancements
  • 8114bda fix: RBAC refinements for SaaS billing model
  • afb524c docs: Fix directory path in BUILD.md (anythingllm not anything-llm)
  • ea249ca docs: Add DEV_SETUP.md with local development instructions
  • 8540ea0 feat: Add multilingual TTS normalizer and STT endpoint
  • d4b7281 fix: Pin n2words to 1.21.0 for Node 18 compatibility
  • 80cb027 feat: Auto-generate weekday/month abbreviations via Intl

📊 Changes

207 files changed (+44061 additions, -684 deletions)

View changed files

.claude/skills/review-code.md (+175 -0)
📝 .gitignore (+2 -0)
BROWSER-TEST-DATEPICKER.md (+226 -0)
BUILD.md (+67 -0)
CHANGELOG.md (+272 -0)
CLAUDE.md (+128 -0)
DEV.md (+61 -0)
DEV_SETUP.md (+119 -0)
ROADMAP.md (+341 -0)
ROLE_UPGRADE_PATH.md (+155 -0)
📝 collector/processLink/convert/generic.js (+93 -22)
📝 collector/processRawText/index.js (+5 -1)
📝 docker/docker-compose.yml (+18 -11)
📝 docker/docker-entrypoint.sh (+35 -1)
docker/get-docker.sh (+694 -0)
frontend/package-lock.json (+8282 -0)
📝 frontend/package.json (+1 -0)
📝 frontend/public/embed/anythingllm-chat-widget.min.css (+1 -1)
📝 frontend/public/embed/anythingllm-chat-widget.min.js (+5 -5)
frontend/public/widget-test.html (+99 -0)

...and 80 more files

📄 Description

Summary

Close Puppeteer browser via try/finally so any error in page.goto, evaluate, or timeout no longer leaks the Chromium process.

Context

Observed on 2026-04-17: intern container accumulated 14 zombie Chromium processes (~2.5 GiB) in 8.4 GiB total RAM after an OpenRouter-auth-cascade. docker restart intern freed 8 GiB and confirmed every zombie was an orphaned Puppeteer Chromium.

Root cause: loader.scrape relied on reaching await browser.close() at the end of the function — but any throw in between (page.goto timeout, waitForFunction failure, evaluate exception) would skip the close.

Changes

  • Wrap scrape() body in try/finally
  • Close browser in finally with .catch() so a close-error doesn't mask the original
  • Remove inner browser.close() from the options.evaluate callback (the outer finally handles it; the inner call was redundant and masked the leak when it threw)

Test plan

  • Syntax check: node --check passes
  • Build AnythingLLM docker image
  • Deploy to intern container first, monitor for 24h — verify no zombies accumulate
  • Roll out to 92 customer containers

Deployment

Important: Fix only takes effect after image rebuild + container rollout. Until then, current containers continue to leak on errors.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/5460 **Author:** [@Alminc91](https://github.com/Alminc91) **Created:** 4/17/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/puppeteer-browser-close-leak` --- ### 📝 Commits (10+) - [`7f1c57a`](https://github.com/Mintplex-Labs/anything-llm/commit/7f1c57a202497bc3c4aaee44d13984ce8ada2e1d) Enhance temperature control and improve OpenAI API consistency - [`c785058`](https://github.com/Mintplex-Labs/anything-llm/commit/c785058384a2e38f9bfd2b2fb15735e9979fee6f) newest embed state - [`83d4c8d`](https://github.com/Mintplex-Labs/anything-llm/commit/83d4c8d047c764c63566870f810a3b175184a536) feat: RBAC enhancements for SaaS billing model v2.2 - [`106433b`](https://github.com/Mintplex-Labs/anything-llm/commit/106433bbd2f91fa6ab8de470d8a66832322a0dc0) Merge upstream/master with RBAC enhancements - [`8114bda`](https://github.com/Mintplex-Labs/anything-llm/commit/8114bda72956d448fb1e747f1dee4e56ce722875) fix: RBAC refinements for SaaS billing model - [`afb524c`](https://github.com/Mintplex-Labs/anything-llm/commit/afb524cfb66d308a66c002eb497865082c43b134) docs: Fix directory path in BUILD.md (anythingllm not anything-llm) - [`ea249ca`](https://github.com/Mintplex-Labs/anything-llm/commit/ea249ca84372c8a3366ba866e81b254304690616) docs: Add DEV_SETUP.md with local development instructions - [`8540ea0`](https://github.com/Mintplex-Labs/anything-llm/commit/8540ea076f7102dd72c6b254b03b615e81c08a8b) feat: Add multilingual TTS normalizer and STT endpoint - [`d4b7281`](https://github.com/Mintplex-Labs/anything-llm/commit/d4b72813169ba2b2b592b20f628356c71d3a52a5) fix: Pin n2words to 1.21.0 for Node 18 compatibility - [`80cb027`](https://github.com/Mintplex-Labs/anything-llm/commit/80cb0277988639122ca54641ff04b755cb007aba) feat: Auto-generate weekday/month abbreviations via Intl ### 📊 Changes **207 files changed** (+44061 additions, -684 deletions) <details> <summary>View changed files</summary> ➕ `.claude/skills/review-code.md` (+175 -0) 📝 `.gitignore` (+2 -0) ➕ `BROWSER-TEST-DATEPICKER.md` (+226 -0) ➕ `BUILD.md` (+67 -0) ➕ `CHANGELOG.md` (+272 -0) ➕ `CLAUDE.md` (+128 -0) ➕ `DEV.md` (+61 -0) ➕ `DEV_SETUP.md` (+119 -0) ➕ `ROADMAP.md` (+341 -0) ➕ `ROLE_UPGRADE_PATH.md` (+155 -0) 📝 `collector/processLink/convert/generic.js` (+93 -22) 📝 `collector/processRawText/index.js` (+5 -1) 📝 `docker/docker-compose.yml` (+18 -11) 📝 `docker/docker-entrypoint.sh` (+35 -1) ➕ `docker/get-docker.sh` (+694 -0) ➕ `frontend/package-lock.json` (+8282 -0) 📝 `frontend/package.json` (+1 -0) 📝 `frontend/public/embed/anythingllm-chat-widget.min.css` (+1 -1) 📝 `frontend/public/embed/anythingllm-chat-widget.min.js` (+5 -5) ➕ `frontend/public/widget-test.html` (+99 -0) _...and 80 more files_ </details> ### 📄 Description ## Summary Close Puppeteer browser via `try/finally` so any error in `page.goto`, `evaluate`, or timeout no longer leaks the Chromium process. ## Context Observed on 2026-04-17: `intern` container accumulated **14 zombie Chromium processes (~2.5 GiB)** in 8.4 GiB total RAM after an OpenRouter-auth-cascade. `docker restart intern` freed 8 GiB and confirmed every zombie was an orphaned Puppeteer Chromium. Root cause: `loader.scrape` relied on reaching `await browser.close()` at the end of the function — but any throw in between (page.goto timeout, waitForFunction failure, evaluate exception) would skip the close. ## Changes - Wrap `scrape()` body in `try/finally` - Close browser in `finally` with `.catch()` so a close-error doesn't mask the original - Remove inner `browser.close()` from the options.evaluate callback (the outer finally handles it; the inner call was redundant and masked the leak when it threw) ## Test plan - [x] Syntax check: `node --check` passes - [ ] Build AnythingLLM docker image - [ ] Deploy to intern container first, monitor for 24h — verify no zombies accumulate - [ ] Roll out to 92 customer containers ## Deployment **Important**: Fix only takes effect after image rebuild + container rollout. Until then, current containers continue to leak on errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 15:21:24 -04:00
yindo closed this issue 2026-06-05 15:21:24 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5453