Skip to content

HTML report page summary breaks when opened without trailing slash (waterfall/screenshots 404) #4608

@davidarny

Description

@davidarny

Have you read the documentation?

  • Yes, I've read the how to make a reproducable bug guide
  • Yes, I've read the how to debug my script guide

URL

Any generated local HTML report page summary URL.

What are you trying to accomplish

Open a generated page summary report and view the waterfall/screenshots reliably regardless of whether the URL is opened as /dir, /dir/ or /dir/index.html.

What browser did you use?

Chrome

How to reproduce

Generate a report for a page whose summary is stored at something like:

  • pages/example_com/path/index.html

Serve the report over HTTP and open the page summary in these two ways:

  • broken: http://localhost:3000/pages/example_com/path
  • works: http://localhost:3000/pages/example_com/path/
  • works: http://localhost:3000/pages/example_com/path/index.html

Actual result

When opened without the trailing slash, the generated page resolves relative paths against the parent path.

The HTML uses relative paths like:

  • data/browsertime.har.gz
  • data/screenshots/...
  • ./1.html
  • metrics.html

So the browser requests the wrong URLs, for example:

  • http://localhost:3000/pages/example_com/data/browsertime.har.gz
  • http://localhost:3000/pages/example_com/data/screenshots/1/afterPageCompleteCheck.jpg

instead of:

  • http://localhost:3000/pages/example_com/path/data/browsertime.har.gz
  • http://localhost:3000/pages/example_com/path/data/screenshots/1/afterPageCompleteCheck.jpg

This causes 404s for HAR/screenshots and the waterfall never loads.

Console output looks like:

GET http://localhost:3000/pages/example_com/data/browsertime.har.gz 404 (Not Found)
GET http://localhost:3000/pages/example_com/data/screenshots/1/afterPageCompleteCheck.jpg 404 (Not Found)
Error: invalid file signature:60,33

60,33 is <!, so the waterfall code appears to be trying to gunzip an HTML 404 page.

Expected result

The generated report should work regardless of whether the page is opened as:

  • /dir
  • /dir/
  • /dir/index.html

or at least fail with a clear error instead of spinning forever.

Notes

I checked the latest npm package too (39.5.0) and the HTML templates still appear to use the same relative paths in the waterfall/page summary templates, and I did not see a <base> tag added for per-page summaries.

Possible fix

Any of these would likely fix it:

  1. Add a <base href=".../"> tag to generated per-page HTML.
  2. Use explicit /index.html consistently in generated/opened URLs.
  3. Add .catch(...) around HAR fetch/decompression so the UI shows a real error instead of infinite loading.

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