sitespeedio / sitespeed.io

sitespeed.io is an open-source tool for comprehensive web performance analysis, enabling you to test, monitor, and optimize your website’s speed using real browsers in various environments.
https://www.sitespeed.io/
MIT License
4.75k stars 602 forks source link

Long URLs being performance tested generate errors #4110

Open 2343909 opened 8 months ago

2343909 commented 8 months ago

Have you read the documentation?

URL

See in the script

What are you trying to accomplish

Here is execution command: _node bin/sitespeed.js -b chrome -n 1 --video --visualMetrics --multi storefront\storefrontfe\src\workflows\demo.mjs

NOTE: If " --visualMetrics" is removed, then it works fine.

What browser did you use?

Chrome

How to reproduce

Run: 
node bin/sitespeed.js -b chrome -n 1  --video --visualMetrics --multi demo.mjs

demo.mjs script
/**
 *
 * @param {import('browsertime').BrowsertimeContext} context
 * @param {import('browsertime').BrowsertimeCommands} commands
 */
export default async function (context, commands) {
    const seleniumWebdriver = context.selenium.webdriver;
    const By = seleniumWebdriver.By;
    const seleniumDriver = context.selenium.driver;
    await seleniumDriver.manage().window().maximize();

    return commands.measure.start(
        'https://???/vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan/473SSFRYKT3.html');
};

OS: 
Windows
Error occurs trying to generate report
If " --visualMetrics" is removed then it works fine.

Log output

INFO: Testing url https://???/vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan/473SSFRYKT3.html iteration 1
[2024-03-06 18:36:06] INFO: Take after page complete check screenshot
[2024-03-06 18:36:07] INFO: Take cumulative layout shift screenshot
[2024-03-06 18:36:08] INFO: Take largest contentful paint screenshot
[2024-03-06 18:36:11] INFO: Use the visual metrics portable script
[2024-03-06 18:36:11] INFO: Get visual metrics from the video
[2024-03-06 18:36:11] ERROR: VisualMetrics failed to run Error: Command failed with exit code 1: python C:\Users\?\Source\sitespeed.io\node_modules\browsertime\visualmetrics\visualmetrics-portable.py --dir C:\Users\??\Source\sitespeed.io\sitespeed-result\demo_mjs\2024-03-06-18-35-50\pages\????\vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan\473SSFRYKT3.html\data\filmstrip\1 --video C:\Users\??\Source\sitespeed.io\sitespeed-result\demo_mjs\2024-03-06-18-35-50\pages\????\vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan\473SSFRYKT3.html\data\video\1.mp4 --orange --force --renderignore 5 --json --viewport --viewportretries 60 --viewportminheight 100 --viewportminwidth 100 -q 75 --logfile C:\Users\????\Source\sitespeed.io\sitespeed-result\demo_mjs\2024-03-06-18-35-50\pages\????\vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan\473SSFRYKT3.html\data\video\1.visualmetrics.log -vvv
C:\Users\???\Source\sitespeed.io\node_modules\browsertime\visualmetrics\visualmetrics-portable.py:502: SyntaxWarning: invalid escape sequence '\.'
  matcher = re.compile(".*com\.android\.version.*")
Traceback (most recent call last):
  File "C:\Users\???\Source\sitespeed.io\node_modules\browsertime\visualmetrics\visualmetrics-portable.py", line 1969, in <module>
    main()
  File "C:\Users\???\Source\sitespeed.io\node_modules\browsertime\visualmetrics\visualmetrics-portable.py", line 1877, in main
    logging.basicConfig(
  File "C:\Python312\Lib\logging\__init__.py", line 2125, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\logging\__init__.py", line 1231, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "C:\Python312\Lib\logging\__init__.py", line 1263, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\???\\Source\\sitespeed.io\\sitespeed-result\\demo_mjs\\2024-03-06-18-35-50\\pages\\????\\vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan\\473SSFRYKT3.html\\data\\video\\1.visualmetrics.log'
C:\Users\????\Source\sitespeed.io\node_modules\browsertime\visualmetrics\visualmetrics-portable.py:502: SyntaxWarning: invalid escape sequence '\.'
  matcher = re.compile(".*com\.android\.version.*")
Traceback (most recent call last):
  File "C:\Users\???\Source\sitespeed.io\node_modules\browsertime\visualmetrics\visualmetrics-portable.py", line 1969, in <module>
    main()
  File "C:\Users\???\Source\sitespeed.io\node_modules\browsertime\visualmetrics\visualmetrics-portable.py", line 1877, in main
    logging.basicConfig(
  File "C:\Python312\Lib\logging\__init__.py", line 2125, in basicConfig
    h = FileHandler(filename, mode,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\logging\__init__.py", line 1231, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "C:\Python312\Lib\logging\__init__.py", line 1263, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\???\\Source\\sitespeed.io\\sitespeed-result\\demo_mjs\\2024-03-06-18-35-50\\pages\\????\\vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan\\473SSFRYKT3.html\\data\\video\\1.visualmetrics.log'
    at makeError (file:///C:/Users/???/Source/sitespeed.io/node_modules/execa/lib/error.js:60:11)
    at handlePromise (file:///C:/Users/????/Source/sitespeed.io/node_modules/execa/index.js:124:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async run (file:///C:/Users/???/Source/sitespeed.io/node_modules/browsertime/lib/video/postprocessing/visualmetrics/visualMetrics.js:129:20)
    at async getVideoMetrics (file:///C:/Users/????/Source/sitespeed.io/node_modules/browsertime/lib/video/postprocessing/visualmetrics/getVideoMetrics.js:33:21)
    at async Video.postProcessing (file:///C:/Users/???/Source/sitespeed.io/node_modules/browsertime/lib/video/video.js:90:22)
    at async Iteration.run (file:///C:/Users/????/Source/sitespeed.io/node_modules/browsertime/lib/core/engine/iteration.js:222:34)
    at async Engine.runByScript (file:///C:/Users/????/Source/sitespeed.io/node_modules/browsertime/lib/core/engine/index.js:308:20)
    at async analyzeUrl (file:///C:/Users/???/Source/sitespeed.io/lib/plugins/browsertime/analyzer.js:190:19)
    at async BrowsertimePlugin.processMessage (file:///C:/Users/???/Source/sitespeed.io/lib/plugins/browsertime/index.js:173:26)
[2024-03-06 18:36:11] ERROR: Could not run Visual Metrics Error: ENOENT: no such file or directory, open 'C:\Users\????\Source\sitespeed.io\sitespeed-result\demo_mjs\2024-03-06-18-35-50\pages\???\vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan\473SSFRYKT3.html\data\video\1.visualmetrics.log''
[2024-03-06 18:36:11] ERROR: Visual Metrics failed to analyse the video Error: ENOENT: no such file or directory, open 'C:\Users\????\Source\sitespeed.io\sitespeed-result\demo_mjs\2024-03-06-18-35-50\pages\????\vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan\473SSFRYKT3.html\data\video\1.visualmetrics.log''
[2024-03-06 18:36:11] ERROR: TypeError: Cannot read properties of undefined (reading 'push')
    at Iteration.run (file:///C:/Users/????/Source/sitespeed.io/node_modules/browsertime/lib/core/engine/iteration.js:246:36)
    at async Engine.runByScript (file:///C:/Users/????/Source/sitespeed.io/node_modules/browsertime/lib/core/engine/index.js:308:20)
    at async analyzeUrl (file:///C:/Users/????/Source/sitespeed.io/lib/plugins/browsertime/analyzer.js:190:19)
    at async BrowsertimePlugin.processMessage (file:///C:/Users/????/Source/sitespeed.io/lib/plugins/browsertime/index.js:173:26)
[2024-03-06 18:36:11] INFO: https://????/vigor-2-piece-non-stick-stainless-steel-aluminum-clad-with-excalibur-coating-fry-pan-set-with-8-and-9-1-2-pan/473SSFRYKT3.html 298 requests, TTFB: 587ms, firstPaint: 1.60s, FCP: 1.60s, DOMContentLoaded: 1.67s, LCP: 1.60s, CLS: 0.001, TBT: 175ms, CPUBenchmark: 33ms, Load: 5.29s
[2024-03-06 18:36:11] INFO: Could not read filmstrip dir TypeError: Cannot read properties of undefined (reading 'time')    at getFilmstrip (file:///C:/Users/????/Source/sitespeed.io/lib/plugins/browsertime/filmstrip.js:200:43)
    at async HTMLBuilder.render (file:///C:/Users/????/Source/sitespeed.io/lib/plugins/html/htmlBuilder.js:285:13)
[2024-03-06 18:36:13] INFO: Could not read filmstrip dir TypeError: Cannot read properties of undefined (reading 'time')    at getFilmstrip (file:///C:/Users/????/Source/sitespeed.io/lib/plugins/browsertime/filmstrip.js:200:43)
    at async HTMLBuilder.render (file:///C:/Users/????/Source/sitespeed.io/lib/plugins/html/htmlBuilder.js:352:13)
[2024-03-06 18:36:15] INFO: HTML stored in C:\Users\????\Source\sitespeed.io\sitespeed-result\demo_mjs\2024-03-06-18-35-50
soulgalore commented 8 months ago

Hi @2343909 thank you for creating the bug report (and including logs etc). There's been a problem on Windows with long URLs if you haven't enabled long file names but this looks like something else. Can you check which Python version you are using, it seems that 3.12 (https://github.com/HandBrake/HandBrake/issues/5454) maybe introduced this?

2343909 commented 8 months ago

Hi @soulgalore Thanks a lot for quick response and yes, I am using Python 3.12.2

soulgalore commented 8 months ago

Hi @2343909 can you try run just a simple test without a scripting and see if you get the same? I tested on Windows with 3.12 and do not get that error. You can checkout the test with Edge and video:

https://github.com/sitespeedio/browsertime/actions/runs/8281202122/job/22659184892

2343909 commented 8 months ago

Hey @soulgalore, I just tried without scripting with Edge and Chrome, the same error occurs . Looks like you are running it with " node bin/browsertime.js" and I am running it with "node bin/sitespeed.js"

soulgalore commented 8 months ago

Yes but sitespeed.io uses browsertime internally. Just wanted to verify, shorter URL works fine for you (just so all dependencies for video recording/analysing is working)? Can you try to remove await seleniumDriver.manage().window().maximize(); from your test and see if that makes any difference? I'm not sure our code handles if you set that directly through selenium.

2343909 commented 7 months ago

@soulgalore I tried it multiple different ways as you have suggested in the previous comment and the outcome is the same specifically for the long URLs. I have executed many different scripts with not as long URLs and it works fine. I removed await seleniumDriver.manage().window().maximize();and still not changes.

soulgalore commented 7 months ago

@2343909 ok. Do you have long paths enabled on your machine as in this PR https://github.com/sitespeedio/browsertime/pull/2040/files ? I want to avoid adding that to the code because it seems strange to edit people properties, but you can manually set it if you don't have already?

2343909 commented 7 months ago

@soulgalore Ok, looks like that is what the issue was... I enabled long paths:

PS C:\WINDOWS\system32> New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

LongPathsEnabled : 1
PSPath           : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
PSParentPath     : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
PSChildName      : FileSystem
PSDrive          : HKLM
PSProvider       : Microsoft.PowerShell.Core\Registry
2343909 commented 7 months ago

@soulgalore However :), there is slight small additional issue when selecting the long URL in the HTML report under the "Page" tab where after clicking on the long URL I get no file found error but if I change the name to something shorter then it works fine: image

Uploading 2024-03-26_14h58_02.mp4…