fix: prevent infinite poll loop on unresponsive browser contexts#23
Open
joaocarlos wants to merge 1 commit intoPleasePrompto:mainfrom
Open
fix: prevent infinite poll loop on unresponsive browser contexts#23joaocarlos wants to merge 1 commit intoPleasePrompto:mainfrom
joaocarlos wants to merge 1 commit intoPleasePrompto:mainfrom
Conversation
Add hard polling guards and browser responsiveness checks in waitForLatestAnswer to avoid CPU spin when page.waitForTimeout returns early in zombie browser states. Also unify recoverable browser error detection and use it in BrowserSession recovery paths for ask/reset/newPage. Refs PleasePrompto#16
b898219 to
0361420
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the infinite/high-CPU polling loop described in #16 when NotebookLM browser context enters a zombie/unresponsive state.
Root Cause
waitForLatestAnswer()relied onpage.waitForTimeout(pollIntervalMs)to pace polling. When the browser/page is unhealthy, this wait can return immediately, turning the loop into a hot spin.Changes
src/utils/browser-errors.tswaitForLatestAnswer()insrc/utils/page-utils.ts:maxPolls)waitForTimeoutreturns too earlypage.evaluate(() => true)+ timeout)src/session/browser-session.ts:newPage,ask, andresetrecovery pathsValidation
npm run buildpasses.node dist/index.js:get_healthOKlist_notebooksOKask_questioncalls OKsession_idunchanged,message_count = 2)waitForTimeoutimmediate return + hangingevaluateBrowser page unresponsive: health check timed out...Issue
Closes #16