繁体   English   中英

更新node.js导致'write EPIPE'与ng e2e

[英]Updating node.js causes 'write EPIPE' with ng e2e

我有一个角度7应用程序,它在服务器上的CI管道中运行其e2e测试。 我的服务器包管理器将node.js版本从10.14更新到10.14.2(两个LTS版本)这导致ng e2e抛出以下错误:

i 「wdm」: Compiled successfully.
[13:38:47] I/update - chromedriver: file exists node_modules\webdriver-manager\selenium\chromedriver_2.45.zip
[13:38:47] I/update - chromedriver: unzipping chromedriver_2.45.zip
[13:38:48] I/update - chromedriver: chromedriver_2.45.exe up to date
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at ChildProcess.target._send (internal/child_process.js:742:20)
    at ChildProcess.target.send (internal/child_process.js:626:19)
    at Observable.rxjs_1.Observable.obs [as _subscribe] (node_modules\@angular-devkit\build-angular\src\utils\run-module-as-observable-fork.js:57:23)
    at Observable._trySubscribe (node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (node_modules\rxjs\internal\Observable.js:30:22)
    at node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (node_modules\rxjs\internal\util\subscribeToResult.js:10:45)
    at MergeMapSubscriber._innerSub (node_modules\rxjs\internal\operators\mergeMap.js:82:29)
    at MergeMapSubscriber._tryNext (node_modules\rxjs\internal\operators\mergeMap.js:76:14)
    at MergeMapSubscriber._next (node_modules\rxjs\internal\operators\mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (node_modules\rxjs\internal\Subscriber.js:67:18)
    at MergeMapSubscriber.notifyNext (node_modules\rxjs\internal\operators\mergeMap.js:92:26)
    at InnerSubscriber._next (node_modules\rxjs\internal\InnerSubscriber.js:28:21)
    at InnerSubscriber.Subscriber.next (node_modules\rxjs\internal\Subscriber.js:67:18)
    at node_modules\rxjs\internal\util\subscribeToPromise.js:7:24
    at process._tickCallback (internal/process/next_tick.js:68:7)
Emitted 'error' event at:
    at process.nextTick (internal/child_process.js:746:39)
    at process._tickCallback (internal/process/next_tick.js:61:11)

当我回滚到10.14 ng e2e再次工作时,我能够在本地重现这一点。

的package.json:

"dependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular/animations": "^7.0.1",
    "@angular/cdk": "^7.0.2",
    "@angular/common": "^7.0.1",
    "@angular/compiler": "^7.0.1",
    "@angular/core": "^7.0.1",
    "@angular/forms": "^7.0.1",
    "@angular/http": "^7.0.1",
    "@angular/material": "^7.0.2",
    "@angular/platform-browser": "^7.0.1",
    "@angular/platform-browser-dynamic": "^7.0.1",
    "@angular/platform-server": "^7.0.1",
    "@angular/router": "^7.0.1",
    "@ng-bootstrap/ng-bootstrap": "^4.0.0",
    "@ngx-translate/core": "^11.0.0",
    "@ngx-translate/http-loader": "^4.0.0",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^4.1.3",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.5.7",
    "devextreme": "18.1.4",
    "devextreme-angular": "18.1.4",
    "devextreme-aspnet-data": "1.4.5",
    "lodash": "^4.17.11",
    "node-sass": "^4.10.0",
    "rxjs": "^6.3.3",
    "toastr": "^2.1.4",
    "webpack": "^4.19.1",
    "zone.js": "^0.8.26"
},
    "devDependencies": {
    "@angular-devkit/core": "0.8.3",
    "@angular/cli": "^7.0.3",
    "@angular/compiler-cli": "^7.0.1",
    "@angular/language-service": "^7.0.1",
    "@babel/core": "^7.1.2",
    "@compodoc/compodoc": "^1.1.5",
    "@storybook/addon-actions": "^4.0.0",
    "@storybook/addon-knobs": "^4.0.0",
    "@storybook/addon-links": "^4.0.0",
    "@storybook/addon-notes": "^4.0.0",
    "@storybook/addons": "^4.0.0",
    "@storybook/angular": "^4.0.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/jquery": "^3.3.9",
    "@types/node": "^10.12.1",
    "@types/react": "^16.4.14",
    "@types/toastr": "^2.1.35",
    "babel-loader": "^8.0.4",
    "codelyzer": "^4.5.0",
    "jasmine": "3.2.0",
    "jasmine-core": "3.2.0",
    "jasmine-reporters": "^2.3.2",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^2.0.1",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "1.3.1",
    "karma-junit-reporter": "^1.2.0",
    "ngx-perfect-scrollbar": "^7.0.0",
    "prettier": "^1.14.3",
    "protractor": "^5.4.1",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "ts-node": "~7.0.1",
    "tslint": "~5.11.0",
    "tslint-config-prettier": "^1.15.0",
    "tslint-plugin-prettier": "^2.0.0",
    "typescript": "^3.1.3",
    "webdriver-manager": "^12.1.0",
    "webpack-bundle-analyzer": "^3.0.3"
}

知道究竟是什么导致了这个以及如何修复它?

事实上,正如其中一条评论所述,更新到最新的Angular CLI版本就完成了这项工作。 修补程序已发布,因此没有必要按照上面链接中的建议降级nodejs

EPIPE错误出现了,因为测试(在TypeScript中)错误地使用了等待。 因此未经处理的Promise拒绝随机发生并导致这些错误。 一旦我修复了不正确的用法,我们就不再在Node 10上出现这些错误了。

尝试仔细检查您的测试是否有错误的等待用法(丢失或冗余)或只是错误的Promise链接(例如,当您忘记从帮助方法返回Promise时)。 在我们的例子中,典型错误是使用:

browser.wait(await EC.invisibilityOf(fade)); // incorrect

代替:

await browser.wait(EC.invisibilityOf(fade)); // correct

更新我的答案替代解决方案

例如,可以在Protractor的onPrepare()钩子中调用以下代码

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;
}

或者一些额外的记录:

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;
}

也许它会帮助那些也有这个问题的人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM