Skip to content

Screenshot fails with timeout error when running in lambdas for some sites #6

@anejaalekh

Description

@anejaalekh

How to reproduce:
Deploy a lambda function with chrome to take the screenshot, try to take the screenshot for https://github.com. You should see the below error in the lambda function logs.

Error in Lambda:
[ERROR] NetworkError: Protocol error Page.captureScreenshot: Target closed.
Traceback (most recent call last):
  File "/var/task/k8_live_servers/lambdas/screenshot.py", line 14, in run
    js_code   = js_code)
  File "/var/task/osbot_browser/browser/Browser_Lamdba_Helper.py", line 17, in get_screenshot_png
    return self.api_browser.sync__screenshot_base64(url, clip=clip,full_page=full_page,delay=delay, js_code=js_code)
  File "/tmp/lambdas-dependencies/syncer/syncer.py", line 44, in run
    return asyncio.get_event_loop().run_until_complete(f(*args, **kwargs))
  File "/var/lang/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/var/task/osbot_browser/browser/API_Browser.py", line 437, in sync__screenshot_base64
    screenshot_file = await self.screenshot(url=url,page=page, full_page=full_page, clip=clip, delay=delay, js_code=js_code)
  File "/var/task/osbot_browser/browser/API_Browser.py", line 231, in screenshot
    await page.screenshot({'path': file_screenshot,'fullPage': full_page, 'clip' : clip})
  File "/tmp/lambdas-dependencies/pyppeteer2/pyppeteer/page.py", line 1255, in screenshot
    return await self._screenshotTask(screenshotType, options)
  File "/tmp/lambdas-dependencies/pyppeteer2/pyppeteer/page.py", line 1302, in _screenshotTask
    result = await self._client.send('Page.captureScreenshot', opt)

To fix that, AWS SAM https://aws.amazon.com/serverless/sam/ can be used to simulate the error locally. Docker image for lambda can be created and that can be used for testing locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions