Skip to content

--timeout 0 option does not disable timeout as expected #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
u1f992 opened this issue Apr 23, 2025 · 1 comment
Open

--timeout 0 option does not disable timeout as expected #575

u1f992 opened this issue Apr 23, 2025 · 1 comment

Comments

@u1f992
Copy link
Contributor

u1f992 commented Apr 23, 2025

ビルドのタイムアウト時間を無制限にするにはpage.setDefaultTimeoutに0を設定すればよいはずですが、--timeout 0ではデフォルト値の120秒が使用されるようです。これは意図された挙動でしょうか?

テスト用HTML生成スクリプト
def format_srgb(n: int, precision: int) -> str:
    if n == 10**precision:
        return "1." + "0" * precision
    s = str(n).rjust(precision, "0")
    return f"0.{s}"


html_head = """<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      @page {
        size: A5;
        margin: 0;
      }
      body {
        font-size: 0;
      }
      div {
        display: inline-block;
        width: 1px;
        height: 1px;
        background-color: black;
      }
    </style>
  </head>
  <body>
"""

html_tail = """  </body>
</html>
"""

precision = 6
max_value = 10**precision

with open("output.html", "w") as f:
    f.write(html_head)
    for i in range(max_value + 1):
        srgb = format_srgb(i, precision)
        f.write(f'<div style="background-color: color(srgb {srgb} 0 0)"></div>')
    f.write(html_tail)
> vivliostyle --version
cli: 8.20.0
core: 2.31.2

> vivliostyle build .\output.html --timeout 0
✖ page.waitForFunction: Timeout 120000ms exceeded.
    at buildPDF (C:\Users\mukai\AppData\Roaming\npm\node_modules\@vivliostyle\cli\dist\output\pdf.js:164:16)
    at async build (C:\Users\mukai\AppData\Roaming\npm\node_modules\@vivliostyle\cli\dist\build.js:84:30)

If you think this is a bug, please report at https://github.com/vivliostyle/vivliostyle-cli/issues

該当箇所をデバッガで確認するとtimout=120000になっていました。

await page.setDefaultTimeout(timeout);
await page.goto(viewerFullUrl, { waitUntil: 'networkidle' });
await page.waitForFunction(() => !!window.coreViewer);
await page.emulateMedia({ media: 'print' });
await page.waitForFunction(
/* v8 ignore next */
() => window.coreViewer.readyState === 'complete',
undefined,
{ polling: 1000 },
);

@u1f992
Copy link
Contributor Author

u1f992 commented Apr 23, 2025

Issueに関連して、デフォルトでタイムアウトが有限になっているのは好ましい挙動ではないように感じており、ご意見を伺いたいです。
どれほど複雑な文書も、原則として十分に時間を与えれば組版処理は完了するはずです。タイムアウトさせるほうが例外的な制御で、ユーザーが明示的にタイムアウトを指定していない場合は完了するまで待つほうが直感的な挙動ではないでしょうか。

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

No branches or pull requests

1 participant