sitespeedio / sitespeedio/sitespeed.io

ERROR: TypeError: Cannot read properties of undefined (reading 'visualMetrics')

Open
#4,168 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
5k
Forks
624
Avg merge
4h 8m
Merged PRs (30d)
2

Description

Have you read the documentation?
URL

https://example.com

What are you trying to accomplish

Getting error with visualmetric please check below code and response

What browser did you use?

Chrome

How to reproduce
Code:

import { run } from 'sitespeed.io';
import fs from 'fs';
import { execSync } from 'child_process';

const outputFolder1 = 'LiveMonitoringResult';
if (!fs.existsSync(outputFolder1)) {
  fs.mkdirSync(outputFolder1);
}

async function runLiveMonitoring() {
  const options = {
    urls: ['https://example.com'], // List of URLs to monitor
    resultBaseDir: outputFolder1, // Directory to store the results
    runs: 1, // Number of runs
    browser: 'chrome', // Browser to use for testing
    connectivity: {
      profile: 'cable', // Network connectivity profile
    },
    live: 5000, // Interval for live monitoring in milliseconds (e.g., 5000 = 5 seconds)
    visualMetrics: false, // Disable visual metrics collection to avoid errors
  };

  try {
    await run(options);
  } catch (error) {
    console.error('Error during live monitoring:', error);
  }
}

// Function to run the monitoring periodically
function startMonitoring(interval) {
  runLiveMonitoring(); // Run immediately
  setInterval(runLiveMonitoring, interval); // Schedule subsequent runs
}

// Start monitoring with a specified interval (e.g., every 5 minutes)
const monitoringInterval = 1 * 60 * 1000; // 5 minutes in milliseconds
startMonitoring(monitoringInterval);
Log output
2024-05-30 12:25:10] ERROR: TypeError: Cannot read properties of undefined (reading 'visualMetrics')
    at getFilmstrip (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/plugins/browsertime/filmstrip.js:180:25)
    at HTMLBuilder.render (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/plugins/html/htmlBuilder.js:283:19)
    at HTMLPlugin.processMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/plugins/html/index.js:226:35)
    at file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:228:32
    at drainItem (/Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/node_modules/concurrent-queue/index.js:96:21)
    at Immediate.drain (/Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/node_modules/concurrent-queue/index.js:77:84)
    at process.processImmediate (node:internal/timers:476:21)
[2024-05-30 12:25:22] INFO: Versions OS: darwin 23.5.0 nodejs: v18.16.0 sitespeed.io: 34.0.1 browsertime: 22.2.0 coach: 8.0.2
[2024-05-30 12:25:22] INFO: Running tests using Chrome - 3 iteration(s)
[2024-05-30 12:25:24] INFO: Testing url https://qa-www.incred.com iteration 1
[2024-05-30 12:25:31] INFO: Take after page complete check screenshot
[2024-05-30 12:25:32] INFO: Take cumulative layout shift screenshot
[2024-05-30 12:25:34] INFO: Take largest contentful paint screenshot
[2024-05-30 12:25:37] INFO: https://qa-www.incred.com TTFB: 64ms DOMContentLoaded: 218ms firstPaint: 756ms FCP: 756ms LCP: 719ms Load: 248ms 
[2024-05-30 12:25:40] INFO: Testing url https://qa-www.incred.com iteration 2
[2024-05-30 12:25:46] INFO: Take after page complete check screenshot
[2024-05-30 12:25:48] INFO: Take cumulative layout shift screenshot
[2024-05-30 12:25:50] INFO: Take largest contentful paint screenshot
[2024-05-30 12:25:53] INFO: https://qa-www.incred.com TTFB: 58ms DOMContentLoaded: 555ms firstPaint: 1.13s FCP: 1.13s LCP: 1.09s Load: 589ms 
[2024-05-30 12:25:56] INFO: Testing url https://qa-www.incred.com iteration 3
[2024-05-30 12:26:02] INFO: Take after page complete check screenshot
[2024-05-30 12:26:04] INFO: Take cumulative layout shift screenshot
[2024-05-30 12:26:05] INFO: Take largest contentful paint screenshot
[2024-05-30 12:26:09] INFO: https://qa-www.incred.com TTFB: 63ms DOMContentLoaded: 293ms firstPaint: 845ms FCP: 845ms LCP: 809ms Load: 324ms 
[2024-05-30 12:26:09] INFO: https://qa-www.incred.com 60 requests, TTFB: 63ms (σ3.00ms 4.3%), firstPaint: 845ms (σ159.00ms 17.5%), FCP: 845ms (σ159.00ms 17.5%), DOMContentLoaded: 293ms (σ144.00ms 40.7%), LCP: 809ms (σ157.00ms 18.0%), CLS: 0 (σ0.00 0%), TBT: 0ms (σ0.00ms 0%), CPUBenchmark: 66ms (σ1.00ms 1.4%), Load: 324ms (σ146.00ms 37.8%) (3 runs)
[2024-05-30 12:26:09] INFO: The server responded with a 403 status code for https://qa-www.incred.com/home/
[2024-05-30 12:26:09] INFO: The server responded with a 403 status code for https://qa-www.incred.com/home/
[2024-05-30 12:26:09] INFO: The server responded with a 403 status code for https://qa-www.incred.com/home/
[2024-05-30 12:26:09] ERROR: Error: Multiple summary messages of type aggregateassets.summary and group total
    at validateSummaryMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:70:11)
    at validateMessageFormat (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:88:3)
    at QueueHandler.postMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:201:5)
    at AssetsPlugin.processMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/plugins/assets/index.js:56:19)
    at file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:228:32
    at drainItem (/Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/node_modules/concurrent-queue/index.js:96:21)
    at Immediate.drain [as _onImmediate] (/Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/node_modules/concurrent-queue/index.js:77:84)
    at process.processImmediate (node:internal/timers:476:21)
file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:70
    throw new Error(
          ^

Error: Multiple summary messages of type browsertime.summary and group total
    at validateSummaryMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:70:11)
    at validateMessageFormat (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:88:3)
    at QueueHandler.postMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/core/queueHandler.js:201:5)
    at BrowsertimePlugin.sendMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/node_modules/@sitespeed.io/plugin/plugin.js:110:23)
    at BrowsertimePlugin.processMessage (file:///Users/madhanumesh/Desktop/GitLoad/LoadTesting/node_modules/sitespeed.io/lib/plugins/browsertime/index.js:619:19)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at process.processImmediate (node:internal/timers:447:9)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied live-monitoring script, then read lib/plugins/browsertime/filmstrip.js and lib/plugins/html/htmlBuilder.js around the visualMetrics failure. Trace the related message flow through lib/core/queueHandler.js, lib/plugins/assets/index.js, and lib/plugins/browsertime/index.js. Done means the reported visualMetrics TypeError and duplicate summary errors no longer occur in the documented scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
performance, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.