Failed: EPIPE write EPIPE frequently seen when SELENIUM_PROMISE_MANAGER: false
Bug report
- Node Version:
6.9.1 - Protractor Version:
5.1.2 - Angular Version:
4.0.0 - Browser(s):
Chrome Version 57.0.2987.133 (64-bit) - Operating System and Version
OS X Version 10.10.5 (14F2315) - Your protractor configuration file
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
/* Third-party */
let HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
let JUnitXmlReporter = require('jasmine-reporters').JUnitXmlReporter;
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
/* Custom */
let setup = require('./e2e/setup/setup');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
SELENIUM_PROMISE_MANAGER: false,
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
jasmine.getEnv().addReporter(new JUnitXmlReporter({
consolidateAll: true,
savePath: browser.params.output || 'protractor/log',
filePrefix: 'protractor_output'
}));
jasmine.getEnv().addReporter(new HtmlScreenshotReporter({
cleanDestination: true,
dest: 'protractor/log',
filename: 'index.html'
}));
setup();
}
};
- A relevant example test
import { browser } from 'protractor';
import { A2Page } from './app.po';
import { NavPartial } from './nav/nav.po';
import { SettingsPage } from './settings/settings.po';
import { Utils } from './utils';
let utils = new Utils();
describe('a2 root', function() {
let page: A2Page = new A2Page();
let navPartial: NavPartial = new NavPartial();
let settingsPage: SettingsPage = new SettingsPage();
it('should be able to navigate to', () => {
return page.navigateTo();
});
it('should take user to Settings', () => {
return settingsPage.getTitle().then(title => {
return expect(title).toEqual('Title');
}).then(() => {
return settingsPage.getSubtitle();
}).then(subtitle => {
return expect(subtitle).toEqual('Subtitle');
});
});
it('should have a Home menu', () => {
return page.navigateTo().then(() => {
return navPartial.isHomePresent();
}).then(present => {
return expect(present).toBeTruthy();
});
});
it('should have an Info menu', () => {
return page.navigateTo().then(() => {
return navPartial.isInfoPresent();
}).then(present => {
return expect(present).toBeTruthy();
});
});
});
- Output from running the test
$ npm run e2e -- --params.baseUrl 'https://myurl'
> [email protected] pree2e /Users/me/a2
> webdriver-manager update
[13:56:14] I/update - chromedriver: file exists /Users/me/a2/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.29.zip
[13:56:14] I/update - chromedriver: unzipping chromedriver_2.29.zip
[13:56:14] I/update - chromedriver: setting permissions to 0755 for /Users/me/a2/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.29
[13:56:14] I/update - chromedriver: chromedriver_2.29 up to date
[13:56:14] I/update - selenium standalone: file exists /Users/me/a2/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar
[13:56:14] I/update - selenium standalone: selenium-server-standalone-3.4.0.jar up to date
[13:56:14] I/update - geckodriver: file exists /Users/me/a2/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.16.1.tar.gz
[13:56:14] I/update - geckodriver: unzipping geckodriver-v0.16.1.tar.gz
[13:56:14] I/update - geckodriver: setting permissions to 0755 for /Users/me/a2/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.16.1
[13:56:14] I/update - geckodriver: geckodriver-v0.16.1 up to date
> [email protected] e2e /Users/me/a2
> $(npm bin)/protractor "--params.baseUrl" "https://myurl"
[13:56:16] I/launcher - Running 1 instances of WebDriver
[13:56:16] I/direct - Using ChromeDriver directly...
Spec started
a2 root
✓ should be able to navigate to
✓ should take user to Settings
✓ should have a Home menu
✗ should have an Info menu
- Failed: EPIPE write EPIPE
**************************************************
* Failures *
**************************************************
1) a2 root should have an Info menu
- Failed: EPIPE write EPIPE
Executed 4 of 4 specs (1 FAILED) in 22 secs.
[13:56:41] I/launcher - 0 instance(s) of WebDriver still running
[13:56:41] I/launcher - chrome #01 failed 1 test(s)
[13:56:41] I/launcher - overall: 1 failed spec(s)
[13:56:41] E/launcher - Process exited with error code 1
npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/me/.nvm/versions/node/v6.9.1/bin/node" "/Users/me/.nvm/versions/node/v6.9.1/bin/npm" "run" "e2e" "--" "--params.baseUrl" "https://myurl"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] e2e: `$(npm bin)/protractor "--params.baseUrl" "https://myurl"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] e2e script '$(npm bin)/protractor "--params.baseUrl" "https://myurl"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the a2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! $(npm bin)/protractor "--params.baseUrl" "https://myurl"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs a2
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls a2
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/me/a2/npm-debug.log
Also excerpt from npm-debug.log:
18 verbose stack Exit status 1
18 verbose stack at EventEmitter.<anonymous> (/Users/me/.nvm/versions/node/v6.9.1/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
18 verbose stack at emitTwo (events.js:106:13)
18 verbose stack at EventEmitter.emit (events.js:191:7)
18 verbose stack at ChildProcess.<anonymous> (/Users/me/.nvm/versions/node/v6.9.1/lib/node_modules/npm/lib/utils/spawn.js:40:14)
18 verbose stack at emitTwo (events.js:106:13)
18 verbose stack at ChildProcess.emit (events.js:191:7)
18 verbose stack at maybeClose (internal/child_process.js:877:16)
18 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
- Steps to reproduce the bug
- Use approximately the Node and Angular versions mentioned, Chrome browser, possibly Mac OS X. (Not yet certain how specific issue is to that combination.)
- Set
SELENIUM_PROMISE_MANAGER: falsein config (disable control flow). - Due to (2) above, use promises everywhere in your test suite.
- Have a suite that for each of several tests, gets a URL and clicks or checks element presence.
- Very quickly you will start hitting
Failed: EPIPE write EPIPEerrors unpredictably.
I'm not using await. I cannot identify any unhandled promises in the test code either (and I'm experienced with promises), although that has been suggested in some of the comments, so I have to allow for that possibility. Still, it's surprising that node would crash on an unhandled promise, if that's the case. So it seems there's a node bug in here somewhere, in addition to whatever problem there may be in my test or protractor or webdriver, etc.
- The URL you are running your tests against (if relevant)
Sorry, it's not public.
I've been bumping into this quite often as well. It seems like it happens more often, maybe exclusively, when Chrome is in the background. Might just be a coincidence
Yes I got this ugly error too!
Apologies for the late response here; I haven't gotten around to reproducing this. Could one of you provide a small example repo (you could use https://github.com/NickTomlin/protractor-mcve as a starter) of an angular 2 app that reproduces this?
Removing the control flow is a step in the right direction but it may be revealing some issues (like this one) that we will need to account for. Thanks!
@NickTomlin @wcainboundary I just upgraded my nodejs to the latest stable version and it works fine now.
Didn't work:
$node -v
v6.10.1
Works fine:
$node -v
v7.10.0
I am seeing the error in node v8.0.0
I'm also seeing this error without protractor (straight [email protected] and I believe 3.3 before it). Never happens on OS X, but quite frequently on our build agents (Linux).
I haven't seen this issue filed against Selenium, but it probably should be.
I have seen this error in OSX.
For me the issue was timing related. My test was trying to interact with an element that was not available. Although the angular tasks were complete some rendering on the page was not complete which led to this issue. It was easier to reproduce on our hosted grid since the connections were slower.
I did see this with waitForAngularEnabled set to true and false.
Prior to upgrading, we used to get timeout errors on some of the same tests. I wonder if Webdriver 3.x is just saying the same thing a different way...
+1 on this, running into the same issue when running my specs locally on OS X 10.12.5
For what it's worth, I was less likely to see the EPIPE error on:
- Node 7.10.1
- OSX 10.12.5
- Protactor 5.1.2
- Chrome 59.0.3071.115
And, when I say less likely, I mean that when I ran my suite 7 times with my above configuration, 4 of the runs were successful if I immediately focused my Chrome browser and didn't move my mouse from the Chrome dock icon (probably not related).
In our project EPIPE errors were appearing, because tests (in TypeScript) were incorrectly using awaits. And therefore unhandled Promise rejections were happening randomly and leading to these errors. Once I've fixed incorrect usages we don't have these errors anymore on Node 8.
Try to check your tests carefully for incorrect usages of await (either missing or redundant) or just incorrect Promise chaining (for example when you forgot to return Promise from helper methods). In our case typical error was using:
browser.wait(await EC.invisibilityOf(fade)); // incorrect
instead of:
await browser.wait(EC.invisibilityOf(fade)); // correct
Maybe it will help somebody, who also has this issue.
Is this issue fixed ? I still see it with node version 7.7.3 and protractor version 5.1.1
@sri1987 see my comment above. It's most likely issue in your code, not in Protractor.
@sri1987 If it's not reproducible consistently it's definitely related to missing/extra await somewhere.
Got these error very often lately with SELENIUM_PROMISE_MANAGER:false When running multiple tests
The issue here and in #4507 seems to be concurrent webdriver commands. @wvanderdeijl suggested a solution for the particular case of ElementArrayFinder::map() in #4508. Until this is resolved properly, the following wrapper for browser.driver.schedule(), which creates a queue to prevent any concurrent webdriver commands being executed, might be a workaround.
Can someone who's experiencing EPIPE-errors regularly test this? It may slow down the test execution to some degree.
The following code can be called in Protractor's onPrepare() hook, for example.
let currentCommand = Promise.resolve();
// Serialise all webdriver commands to prevent EPIPE errors
const webdriverSchedule = browser.driver.schedule;
browser.driver.schedule = (command: Command, description: string) => {
currentCommand = currentCommand.then(() =>
webdriverSchedule.call(browser.driver, command, description)
);
return currentCommand as any;
}
or with some additional logging:
let currentCommand = Promise.resolve();
let concurrencyCounter = 0;
// Serialise all webdriver commands to prevent EPIPE errors
const webdriverSchedule = browser.driver.schedule;
browser.driver.schedule = (command: Command, description: string) => {
console.log(`${++concurrencyCounter} concurrent webdriver command(s). Latest command: ${description}`);
currentCommand = currentCommand.then(() =>
webdriverSchedule.call(browser.driver, command, description)
.then(result => {
concurrencyCounter--;
return result;
})
.catch(error => {
concurrencyCounter--;
//console.lgErrLabel('Webdriver error')(command, description, error);
console.error('Webdriver error:', command, description, error);
throw error;
})
);
return currentCommand as any;
}
@renehamburger I think you are spot on there. I narrowed down most of my errors were coming from functions which returns a Promise.all call so i'm quite sure it must have something to do with concurrency
@renehamburger thank you. After add this one to onPrepare section of my protractor.conf.js:
let currentCommand = Promise.resolve();
// Serialise all webdriver commands to prevent EPIPE errors
const webdriverSchedule = browser.driver.schedule;
browser.driver.schedule = (command, description) => {
currentCommand = currentCommand.then(() =>
webdriverSchedule.call(browser.driver, command, description)
);
return currentCommand;
};
Error 'Failed: EPIPE write EPIPE' is gone.
@Xaz16: Worked for us as workaround, thanks!
But the "EPIPE write EPIPE" erroms seems to be a bug in Selenium: https://github.com/SeleniumHQ/selenium/issues/5345 which will be solved in 4.0.0.
So we have to wait until Protractor uses 4.0.0 version and the we can remove this workaround.
Do we have some link to Protractor roadmap? Or it doesn't exist at all