Skip to content

fix(browser): treat screenshot failure as non-critical warning#159

Open
haosenwang1018 wants to merge 1 commit intovxcontrol:masterfrom
haosenwang1018:fix/browser-screenshot-non-critical
Open

fix(browser): treat screenshot failure as non-critical warning#159
haosenwang1018 wants to merge 1 commit intovxcontrol:masterfrom
haosenwang1018:fix/browser-screenshot-non-critical

Conversation

@haosenwang1018
Copy link

Summary

Fixes #149

The browser tool's ContentMD, ContentHTML, and Links methods 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:

  • Scraper service being temporarily unavailable or restarting
  • Network timeout (65s hard timeout)
  • Target page producing a screenshot smaller than minImgContentSize (2048 bytes)
  • Disk write failure in writeScreenshotToFile

Since 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(), and Links():

  • Screenshot errors are now logged as warnings via logrus.WithError(...).Warnf()
  • screenshotName is set to empty string on failure
  • Valid content is returned instead of being discarded

Before / 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.

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
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.

[Bug]: Browser tool discards successfully-fetched page content when screenshot fails

1 participant