fix(browser): treat screenshot failure as non-critical warning#159
Open
haosenwang1018 wants to merge 1 commit intovxcontrol:masterfrom
Open
fix(browser): treat screenshot failure as non-critical warning#159haosenwang1018 wants to merge 1 commit intovxcontrol:masterfrom
haosenwang1018 wants to merge 1 commit intovxcontrol:masterfrom
Conversation
When ContentMD, ContentHTML, or Links successfully fetch page content but screenshot capture fails, log a warning and return the content instead of discarding it and returning an error. Screenshot failures can occur due to scraper service unavailability, timeouts, or pages producing screenshots below the minimum size threshold. Since the screenshot is a non-critical side-effect (the caller already ignores PutScreenshot errors), it should not abort the entire browser operation. Fixes vxcontrol#149
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 #149
The browser tool's
ContentMD,ContentHTML, andLinksmethods run content fetching and screenshot capture concurrently. Currently, if the screenshot fails for any reason, the entire operation returns an error — discarding successfully-fetched page content.This PR makes screenshot failure non-critical: when content is successfully fetched but the screenshot fails, a warning is logged and the content is returned with an empty screenshot name.
Problem
Screenshot failures can occur due to:
minImgContentSize(2048 bytes)writeScreenshotToFileSince the caller (
wrapCommandResult) already treats the screenshot as optional (_, _ = b.scp.PutScreenshot(...)), the screenshot result is already considered disposable at the call-site. Yet the producing function can abort the entire operation.Changes
In
ContentMD(),ContentHTML(), andLinks():logrus.WithError(...).Warnf()screenshotNameis set to empty string on failureBefore / After
Before: Agent receives
browser tool 'markdown' handled with error: failed to fetch screenshot...even though content was fetched successfully.After: Agent receives the page content. A warning is logged for debugging.