Skip to content

Commit

Permalink
fix browser crashes (#3124)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Nov 11, 2021
1 parent b2253d0 commit 1b37997
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
## 3.2.1

> ♻️ This release fixes hanging of tests by reducing timeouts for automatic retries on failures.
* [retryFailedStep plugin] **New Defaults**: retries steps up to 3 times with factor of 1.5 (previously 5 with factor 2)
* [Playwright] - disabled retry on failed context actions (not needed anymore)
* [Puppeteer] - reduced retries on context failures to 3 times.
* [Playwright] Handling `crash` event to automatically close crashed pages.

## 3.2.0

🛩️ Features:

**[Timeouts](https://codecept.io/advanced/#timeout) implemented**
* global timeouts (via `timeout` config option).
* _Breaking change:_ timeout option expects **timeout in seconds**, not in miliseconds as it was previously.
* _Breaking change:_ timeout option expects **timeout in seconds**, not in milliseconds as it was previously.
* test timeouts (via `Scenario` and `Feature` options)
* _Breaking change:_ `Feature().timeout()` and `Scenario().timeout()` calls has no effect and are deprecated

Expand Down
15 changes: 5 additions & 10 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,6 @@ class Playwright extends Helper {
}

async _before() {
recorder.retry({
retries: 5,
when: err => {
if (!err || typeof (err.message) !== 'string') {
return false;
}
// ignore context errors
return err.message.includes('context');
},
});
if (this.options.restart && !this.options.manualStart) await this._startBrowser();
if (!this.isRunning && !this.options.manualStart) await this._startBrowser();

Expand Down Expand Up @@ -578,6 +568,11 @@ class Playwright extends Helper {
this.page = page;
if (!page) return;
page.setDefaultNavigationTimeout(this.options.getPageTimeout);

page.on('crash', async () => {
console.log('ERROR: Page has crashed, closing page!');
await page.close();
});
this.context = await this.page;
this.contextLocator = null;
if (this.options.browser === 'chrome') {
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/Puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Puppeteer extends Helper {
async _before() {
this.sessionPages = {};
recorder.retry({
retries: 5,
retries: 3,
when: err => {
if (!err || typeof (err.message) !== 'string') {
return false;
Expand Down
7 changes: 4 additions & 3 deletions lib/plugin/retryFailedStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const event = require('../event');
const recorder = require('../recorder');

const defaultConfig = {
retries: 5,
retries: 3,
defaultIgnoredSteps: [
'amOnPage',
'wait*',
Expand All @@ -11,6 +11,7 @@ const defaultConfig = {
'run*',
'have*',
],
factor: 1.5,
ignoredSteps: [],
};

Expand All @@ -36,9 +37,9 @@ const defaultConfig = {
*
* #### Configuration:
*
* * `retries` - number of retries (by default 5),
* * `retries` - number of retries (by default 3),
* * `when` - function, when to perform a retry (accepts error as parameter)
* * `factor` - The exponential factor to use. Default is 2.
* * `factor` - The exponential factor to use. Default is 1.5.
* * `minTimeout` - The number of milliseconds before starting the first retry. Default is 1000.
* * `maxTimeout` - The maximum number of milliseconds between two retries. Default is Infinity.
* * `randomize` - Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is false.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeceptjs",
"version": "3.2.0",
"version": "3.2.1",
"description": "Supercharged End 2 End Testing Framework for NodeJS",
"keywords": [
"acceptance",
Expand Down

0 comments on commit 1b37997

Please sign in to comment.