Skip to content

*_to_pic 工具函数不支持远程连接浏览器的场景 #118

@AzideCupric

Description

@AzideCupric

这些*_to_pic 的函数都会指定 html_to_pic 函数的 template_path 参数为某个文件 file://xxx

template_path=f"file://{css_path or TEMPLATES_PATH}",

html_to_pic 会让浏览器 goto 这个文件

if "file:" not in template_path:
raise Exception("template_path should be file:///path/to/template")
async with get_new_page(device_scale_factor, **kwargs) as page:
page.on("console", lambda msg: logger.debug(f"[Browser Console]: {msg.text}"))
await page.goto(template_path)

但是在浏览器和nb分离部署的时候(HTMLRENDER_CONNECT=xxx),浏览器那边可能不会存在这个路径,导致爆炸。
可以考虑

  1. 添加参数goto_url="about:blank"默认跳转到goto_url
  2. template_path默认值改为"about:blank",但是html_to_pic里会检查url是否以"file://"开头,并且语义不是很明确(

发现这个的原因是 bison 想分离浏览器,但是测试炸掉了: failed test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions