Skip to content

Commit 35073cb

Browse files
committed
ci: fix saucelabs browser crashing due to idle timeout
In the past when the Angular Team reworked the Saucelabs Karma launcher the Saucelabs Selenium heartbeat has been removed in favor of people just increasing the Saucelabs `idleTimeout` to the max minutes their test will run. The `idleTimeout` is limited to a 16min right now, so we need to get back to the approach relying on a Selenium heartbeat. For reference: The heartbeat refers to the Karma launcher performing an arbitrary Selenium command every X seconds. This helps with keeping the Saucelabs browser alive. Currently we exceed the `idleTimeout` of 16min and the browsers start to crash. Karma re-starts the browser. This results in increased time for the Saucelabs test to ~30min from ~15min. We fix this by upating the Karma Saucelabs launcher to a version that has been improved by the Saucelabs team. We were always hestitant to updating because it took a lot effort to get the Saucelabs karma launcher stable (in the past it was _super_ flaky with the heartbeat and implementation), but it's worth another try given we now exceed the ~16min due to more tests being added. Long-term we want to switch the Saucelabs/Browserstack tests to fine-grained Bazel test targets that can be tested incrementally. There is work in progress for this, but it's not prioritized. This commit additionally updates the Saucelabs test from iOS13 to iOS14 with a more recent emulator, hoping for better specs of the Saucelabs VM and emulator. Note: We also need to add a new Yarn resolution that updates nested `https-proxy-agent` dependencies. Packages like the browserstack launcher install old versions that patch the NodeJS native `http.request` method and break `webdriverio` starting a remote Saucelabs session.
1 parent 24c35a4 commit 35073cb

File tree

6 files changed

+1310
-124
lines changed

6 files changed

+1310
-124
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
"karma-jasmine": "^4.0.1",
194194
"karma-parallel": "^0.3.0",
195195
"karma-requirejs": "^1.1.0",
196-
"karma-sauce-launcher": "^2.0.2",
196+
"karma-sauce-launcher": "^4.3.6",
197197
"karma-sourcemap-loader": "^0.3.7",
198198
"madge": "^4.0.0",
199199
"marked": "^2.0.0",
@@ -231,6 +231,7 @@
231231
},
232232
"resolutions": {
233233
"browser-sync-client": "2.26.13",
234-
"dgeni-packages/typescript": "4.3.2"
234+
"dgeni-packages/typescript": "4.3.2",
235+
"**/https-proxy-agent": "5.0.0"
235236
}
236237
}

test/browser-providers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
const browserConfig = {
1010
'Edge87': {unitTest: {target: 'browserstack'}},
11-
'iOS13': {unitTest: {target: 'saucelabs'}},
11+
'iOS14': {unitTest: {target: 'saucelabs'}},
1212
'Safari13': {unitTest: {target: 'browserstack'}},
1313
};
1414

test/karma-browsers.json

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
{
2-
"ChromeHeadlessCI": {
3-
"base": "ChromeHeadless",
4-
"flags": [
5-
"--window-size=1024,768",
6-
"--no-sandbox"
7-
]
8-
},
9-
"ChromeLocalDebug": {
10-
"base": "Chrome",
11-
"flags": [
12-
"--window-size=1024,768"
13-
]
14-
},
15-
"SAUCELABS_IOS13": {
2+
"SAUCELABS_IOS14": {
163
"base": "SauceLabs",
4+
"appiumVersion": "1.20.1",
5+
"deviceOrientation": "portrait",
176
"browserName": "Safari",
18-
"platformVersion": "13.2",
7+
"platformVersion": "14.3",
198
"platformName": "iOS",
20-
"deviceName": "iPhone XS Simulator"
9+
"deviceName": "iPhone 12 Pro Simulator"
2110
},
2211
"BROWSERSTACK_EDGE87": {
2312
"base": "BrowserStack",

test/karma.conf.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ module.exports = config => {
77
frameworks: ['jasmine'],
88
middleware: ['fake-url'],
99
plugins: [
10-
require('karma-jasmine'), require('karma-browserstack-launcher'),
11-
require('karma-sauce-launcher'), require('karma-chrome-launcher'),
12-
require('karma-firefox-launcher'), require('karma-sourcemap-loader'), {
10+
require('karma-jasmine'),
11+
require('karma-browserstack-launcher'),
12+
require('karma-sauce-launcher'),
13+
require('karma-sourcemap-loader'), {
1314
'middleware:fake-url': [
1415
'factory',
1516
function() {
@@ -107,7 +108,7 @@ module.exports = config => {
107108
browserDisconnectTolerance: 1,
108109
browserNoActivityTimeout: 300000,
109110

110-
browsers: ['ChromeLocalDebug'],
111+
browsers: [],
111112
singleRun: false,
112113

113114
// Try Websocket for a faster transmission first. Fallback to polling if necessary.

tools/package-tools/ts-compile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import * as chalk from 'chalk';
1111
export function tsCompile(binary: 'tsc' | 'ngc', flags: string[]) {
1212
return new Promise<void>((resolve, reject) => {
1313
const binaryPath = resolvePath(`./node_modules/typescript/bin/${binary}`);
14-
const childProcess = spawn(binaryPath, flags, {shell: true});
14+
// Use `node` for spawning the TypeScript compiler. On Windows, the shell is
15+
// not necessarily able to detect that the `tsc` files relies on Node.
16+
const childProcess = spawn('node', [binaryPath, ...flags], {shell: true});
1517

1618
// Pipe stdout and stderr from the child process.
1719
childProcess.stdout.on('data', (data: string|Buffer) => console.log(`${data}`));

0 commit comments

Comments
 (0)