question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Runs on a Single URL

See original GitHub issue

I have been trying to write a script that allows me to pass in a list of URLs run each URL multiple times, collect the data grab the find the median for each URL then write out to a separate HTML/JSON file the processed data from the batch runs. With the script in its early stages I still can’t seem to get a successful run. It is giving me a

SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at Object.<anonymous> (.\Lighthouse\runLighthouseMulti.js:20:25)

This is my current code

`#!/usr/bin/env node

const spawnSync = require(‘child_process’).spawnSync; const lighthouseCli = require.resolve(‘./lighthouse/lighthouse-cli’); let urls = require(‘./Lighthouse/urls.json’); // The file where your list of urls lives let runs = 0

for (const url of urls) { // console.log(url.url); console.log(Running performance test ${runs + 1}); // Logs this to the console just before it kicks off try { const { status = -1, stdout } = spawnSync(‘node’, [lighthouseCli, ‘https://www.example.com’, ‘–config-path=“./Lighthouse/custom-config.js”’, --chrome-flags="--headless --user-agent='Custom'", ‘–emulated-form-factor none’, ‘–output=json’ ]); // Executes this on the command line to run the performance test console.log(stdout.toString()); console.log(JSON.parse(stdout)); } catch(err) { console.log(err) console.log(Performance test ${runs + 1} failed); // If Lighthouse happens to fail it’ll log this to the console and log the error message break; } console.log(Finished running performance test ${url.fileName} ${runs + 1}); // Logs this to the console just after it finishes running each performance test runs++; } console.log(All finished);`

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

0reactions
patrickhulcecommented, Oct 27, 2020

We’re going to go ahead and close this out as there’s no action for Lighthouse to take here. Further direct questions might be better served by the community at Stack Overflow 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run multiple urls in single session - Help
Use Open browser to open the browser; send hot key CTRL + T to open new tab and; Use Type into activity to...
Read more >
Multiple GETs in URL at the same time? - Stack Overflow
URLs are either absolute, starting from the base path, relative to the current direction, or relative to the current page when just the...
Read more >
Stacking Multiple URLs/Endpoints in a Single Request
Learn how to stack multiple URLs /endpoints in a single request in Apipheny. This feature lets you simplify your daily data tasks by...
Read more >
What is the Multiple URL Opener Tool? - Website Planet
The Multiple URL Opener is a tool that allows you to open multiple URLs simultaneously. You can either manually input the URLs or...
Read more >
Open multiple URLs or links at once in a single click
There are many websites which can open many URLs simultaneously. Check out a few of such websites and extensions which helps you to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found