-
Notifications
You must be signed in to change notification settings - Fork 216
Open
Description
Summary
The NotebookLM MCP server can get stuck in an infinite loop consuming 100% CPU for days when the underlying browser context becomes unresponsive or enters a zombie state.
Observed Behavior
- Process running at 100% CPU continuously for 80+ hours (4834 minutes CPU time)
-
- Only resolved by
kill -9(regularkillwas ineffective)
- Only resolved by
-
-
- Process command:
node /Users/.../.npm/_npx/.../node_modules/.bin/notebooklm-mcp
- Process command:
-
Root Cause Analysis
After examining the source code, the issue appears to be in page-utils.js in the waitForLatestAnswer() function:
while (Date.now() < deadline) { // 2 minute timeout
pollCount++;
// ... polling logic ...
await page.waitForTimeout(pollIntervalMs); // Should wait 1 second
}What happens:
- The Chromium browser (managed by Patchright) becomes unresponsive or enters a bad state
-
page.waitForTimeout(1000)returns immediately instead of waiting 1 second (because the browser connection is broken)
-
- The while loop becomes a tight spin loop with no actual waiting
-
- The 2-minute
deadlinenever triggers becauseDate.now()is called, but the CPU is saturated
Why detection fails:
The recovery logic checks for specific error messages:
- The 2-minute
if (/has been closed|Target .* closed|Browser has been closed|Context .* closed/i.test(msg))But a zombie browser (unresponsive but not cleanly closed) doesn't trigger these patterns.
Suggested Fixes
- Add maximum poll count limit:
-
- const MAX_POLLS = 7200; // 2 hours max at 1s intervals
- while (Date.now() < deadline && pollCount < MAX_POLLS) {
-
- Add health check for the page:
-
- try {
-
await page.evaluate(() => true); // Simple aliveness check - } catch {
-
throw new Error("Browser page unresponsive"); - }
-
- Exponential backoff on repeated empty polls
Environment
- Node.js: v20+
-
- notebooklm-mcp version: 1.2.1
-
-
- OS: macOS (Darwin)
-
-
-
-
- Patchright/Playwright version: 1.48.2
-
-
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels