Skip to content

Commit

Permalink
Create and reuse one puppeteer browser, see #150
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jul 7, 2022
1 parent 21ce8eb commit ec48b30
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions js/server/QuickServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const _ = require( 'lodash' ); // eslint-disable-line
const path = require( 'path' );
const url = require( 'url' );
const winston = require( 'winston' );
const puppeteer = require( 'puppeteer' );
const sendSlackMessage = require( './sendSlackMessage' );

const ctqType = {
Expand Down Expand Up @@ -74,6 +75,29 @@ class QuickServer {
let forceTests = true;
let count = 0;

// Launch the browser once and reuse it to generate new pages in puppeteerLoad
const browser = await puppeteer.launch( {

// With this flag, temp files are written to /tmp/ on bayes, which caused https://github.com/phetsims/aqua/issues/145
// /dev/shm/ is much bigger
ignoreDefaultArgs: [ '--disable-dev-shm-usage' ],

// Command line arguments passed to the chrome instance,
args: [
'--enable-precise-memory-info',

// To prevent filling up `/tmp`, see https://github.com/phetsims/aqua/issues/145
`--user-data-dir=${process.cwd()}/../tmp/puppeteerUserData/`
]
} );

const puppeteerOptions = {
waitAfterLoad: 10000,
allowedTimeToLoad: 120000,
puppeteerTimeout: 120000,
browser: browser
};

while ( true ) { // eslint-disable-line

try {
Expand Down Expand Up @@ -136,26 +160,6 @@ class QuickServer {

winston.info( 'QuickServer: sim fuzz' );

const puppeteerOptions = {
waitAfterLoad: 10000,
allowedTimeToLoad: 120000,
puppeteerTimeout: 120000,
launchOptions: {

// With this flag, temp files are written to /tmp/ on bayes, which caused https://github.com/phetsims/aqua/issues/145
// /dev/shm/ is much bigger
ignoreDefaultArgs: [ '--disable-dev-shm-usage' ],

// Command line arguments passed to the chrome instance,
args: [
'--enable-precise-memory-info',

// To prevent filling up `/tmp`, see https://github.com/phetsims/aqua/issues/145
`--user-data-dir=${process.cwd()}/../tmp/puppeteerUserData/`
]
}
};

let simFuzz = null;
try {
await withServer( async port => {
Expand Down

0 comments on commit ec48b30

Please sign in to comment.