Skip to content

Commit

Permalink
Add delay when starting multiple Chrome instances on Mac (closes DevE…
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyBelym authored and kirovboris committed Dec 18, 2019
1 parent 01ff6f6 commit a60d776
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/browser/provider/built-in/chrome/local-chrome.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import OS from 'os-family';
import Promise from 'pinkie';
import browserTools from 'testcafe-browser-tools';
import killBrowserProcess from '../../utils/kill-browser-process';
import delay from '../../../../utils/delay';


const MACOS_PROCESS_THROTTLING = 500;

var throttlingPromise = Promise.resolve();

function buildChromeArgs (config, cdpPort, platformArgs, profileDir) {
return []
.concat(
Expand All @@ -20,7 +27,13 @@ export async function start (pageUrl, { browserName, config, cdpPort, tempProfil

chromeOpenParameters.cmd = buildChromeArgs(config, cdpPort, chromeOpenParameters.cmd, tempProfileDir);

await browserTools.open(chromeOpenParameters, pageUrl);
var currentThrottlingPromise = throttlingPromise;

if (OS.mac)
throttlingPromise = throttlingPromise.then(() => delay(MACOS_PROCESS_THROTTLING));

await currentThrottlingPromise
.then(() => browserTools.open(chromeOpenParameters, pageUrl));
}

export async function stop ({ browserId }) {
Expand Down

0 comments on commit a60d776

Please sign in to comment.