Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

shardTestFiles seems to result in intermittent EADDRINUSE errors #4091

Closed
massimocode opened this issue Feb 14, 2017 · 5 comments
Closed

shardTestFiles seems to result in intermittent EADDRINUSE errors #4091

massimocode opened this issue Feb 14, 2017 · 5 comments

Comments

@massimocode
Copy link
Contributor

We are intermittently seeing the following errors in our TeamCity build logs since enabling shardTestFiles:

[I should REDACTED] Error: Error: Error while running module script app.date.service: EADDRINUSE connect EADDRINUSE 10.242.4.15:51158
    at wrappedReject (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\jasminewd2\index.js:89:32)
    at ManagedPromise.invokeCallback_ (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:1366:14)
    at TaskQueue.execute_ (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:2970:14)
    at TaskQueue.executeNext_ (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:2953:27)
    at asyncRun (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:2813:27)
    at C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:676:7
    at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: Run beforeEach in control flow
    at Object.<anonymous> (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\jasminewd2\index.js:86:14)
    at attemptAsync (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1916:24)
    at QueueRunner.run (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1871:9)
    at C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16
    at C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1842:9
    at C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\jasminewd2\index.js:61:7
    at ControlFlow.emit (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\events.js:62:21)
    at ControlFlow.shutdown_ (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:2565:10)
    at shutdownTask_.MicroTask (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:2490:53)
    at MicroTask.asyncRun (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\selenium-webdriver\lib\promise.js:2619:9)
From asynchronous test: 
Error
    at Suite.describe (C:\BuildAgent\work\5d4c0dd4e428c81b\protractor-tests\ui_tests\REDACTED.specs.ts:21:9)
    at addSpecsToSuite (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:833:25)
    at Env.describe (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:802:7)
    at jasmineInterface.describe (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3375:18)
    at Suite.describe (C:\BuildAgent\work\5d4c0dd4e428c81b\protractor-tests\ui_tests\REDACTED.specs.ts:20:5)
    at addSpecsToSuite (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:833:25)
    at Env.describe (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:802:7)
    at jasmineInterface.describe (C:\BuildAgent\work\5d4c0dd4e428c81b\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3375:18)
    at Object.<anonymous> (C:\BuildAgent\work\5d4c0dd4e428c81b\protractor-tests\ui_tests\REDACTED.specs.ts:13:1)

We are running the following config:

import { browser } from "protractor";
import disableAnimation from "../disable-animation";
import ScreenshotReporter from "../utils/screenshot-reporter";

export let config = {
    allScriptsTimeout: 20000,
    specs: [
        "./**/*specs.js"
    ],
    capabilities: {
        "browserName": "chrome",
        "chromeOptions": {
            args: ["--test-type", "--no-sandbox"]
        },
        shardTestFiles: true,
        maxInstances: process.env.NUMBER_OF_PROCESSORS || 4
    },
    baseUrl: "http://localhost:56549/",
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 2 * 60 * 1000
    },
    onPrepare: function () {
        browser.addMockModule("disableAnimation", disableAnimation);

        // width x height
        let width = 1000, height = 800;
        browser.driver.manage().window().setSize(width, height);

        // Remove jasmine's default reporter
        require("jasmine").prototype.configureDefaultReporter = () => { };

        jasmine.getEnv().addReporter(new ScreenshotReporter("./protractor-tests/ui_tests/screenshots", false));

        let reporters = require("jasmine-reporters");
        if (process.env.TEAMCITY_VERSION) {
            jasmine.getEnv().addReporter(new reporters.TeamCityReporter());
        } else {
            jasmine.getEnv().addReporter(new reporters.TerminalReporter({ verbosity: 3, color: true }));
        }
    },
    params: require("../config-param.json")
};

Here is our package.json

{
  "name": "REDACTED",
  "version": "0.0.0",
  "description": "REDACTED",
  "main": "Gruntfile.js",
  "scripts": {
    "postinstall": "node node_modules/protractor/bin/webdriver-manager update",
    "preinstall": "PowerShell -Command \"Stop-Process -Name chromedriver* -Force\"",
    "test": "grunt test",
    "e2etest": "grunt e2e_test",
    "install": "npm run compile && npm run compile-sass && grunt ngtemplates",
    "compile": "node node_modules/typescript/bin/tsc -p protractor-tests/tsconfig.json",
    "compile-sass": "grunt sass"
  },
  "repository": {
    "type": "git",
    "url": "REDACTED"
  },
  "devDependencies": {
    "@types/angular": "^1.5.20",
    "@types/angular-animate": "^1.5.5",
    "@types/angular-mocks": "0.0.0",
    "@types/jasmine": "^2.5.38",
    "@types/mssql": "^3.1.30",
    "@types/node": "0.0.2",
    "@types/request-promise": "^4.1.33",
    "@types/selenium-webdriver": "^2.53.38",
    "eslint": "^3.11.1",
    "grunt": "~0.4.1",
    "grunt-angular-templates": "^1.1.0",
    "grunt-cli": "~0.1.13",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-exec": "^1.0.1",
    "grunt-iisexpress": "*",
    "grunt-sass": "^1.2.1",
    "jasmine-reporters": ">2.0.0",
    "mssql": "*",
    "promise-mysql": "^1.3.2",
    "protractor": "5.0.0",
    "request-promise": "^4.1.1",
    "tslint": "^4.0.2",
    "typescript": "^2.1.5"
  },
  "author": " ",
  "license": "ISC",
  "dependencies": {}
}

Here is our grunt file

module.exports = function (grunt) {

    grunt.initConfig({
        exec: {
            protractor: {
                command: function (folder) {
                    return `node node_modules/protractor/bin/protractor protractor-tests/${folder}/protractor.conf.js`
                },
                callback: function() {
                    console.log('Killing IIS Express')
                    grunt.event.emit('mytasks.done');
                }
            }
        },
        iisexpress: {
            server: {
                options: {
                    killOn: 'mytasks.done',
                    port: 56549,
                    path: 'src/REDACTED'
                }
            }
        },
        sass: {
            options: {
                sourceMap: true,
                outputStyle: 'compressed'
            },
            dist: {
                files: {
                    'src/REDACTED/Content/css/package.css': 'src/REDACTED/Content/scss/package.scss'
                }
            }
        },
        watch: {
            sass: {
                files: ['src/REDACTED/Content/scss/*.scss'],
                tasks: ['sass']
            },
        },
        ngtemplates: {
            app: {
                cwd: 'src/REDACTED',
                src: 'Scripts/app/**/*.html',
                dest: 'src/REDACTED/Scripts/templates/app.templates.js'
            }
        }
    });

    grunt.loadNpmTasks('grunt-iisexpress');
    grunt.loadNpmTasks('grunt-exec');
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-angular-templates');

    grunt.registerTask('test', ['iisexpress', 'exec:protractor:ui_tests']);
    grunt.registerTask('default', ['test']);
    grunt.registerTask('e2e_test', ['exec:protractor:e2e_tests']);
    grunt.registerTask('sass-watch', ['watch:sass']);
};
@NickTomlin
Copy link
Contributor

Interesting, what is running at 10.242.4.15:51158 ? Can you reproduce this locally?

Thanks for providing a very in depth example, unfortunately it's going to be a bit hard to unpack this given the size and the environment (we can't officially support team city or any CI system here). I'm happy to talk this out further in this issue but the end result is that this is probably better handled in a more focused forum like StackOverflow or a team city dedicated issue queue.

@wswebcreation
Copy link
Contributor

@massimocode

Are you sill facing the problem?
This issue is also open a long time and has no activity after @NickTomlin his comment. If there is no activity within the coming week I'll close the issue.

Grtz

wswebcreation

@mwager
Copy link

mwager commented Oct 26, 2017

We are having the same problem on vsts CI agents. Cannot reproduce locally. We disabled shard again but it would be really nice to use it...

package.json:

    "protractor": "5.2.0"

@nayanr9
Copy link

nayanr9 commented Apr 10, 2019

I am getting this issue now in 2019, not sure if there was a solution for this.?
Any Help Plz.

Failed: EADDRINUSE connect EADDRINUSE 127.0.0.1:57299
Error: EADDRINUSE connect EADDRINUSE 127.0.0.1:57299
at ClientRequest. (C:\portal\angular\node_modules\selenium-webdriver\http\index.js:238:15)
at ClientRequest.emit (events.js:182:13)
at Socket.socketErrorListener (http_client.js:392:9)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process.tickCallback (internal/process/next_tick.js:63:19)
From: Task: WebElement.isEnabled()
at Driver.schedule (C:\portal\angular\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at WebElement.schedule
(C:\portal\angular\node_modules\selenium-webdriver\lib\webdriver.js:2010:25)
at WebElement.isEnabled (C:\portal\angular\node_modules\selenium-webdriver\lib\webdriver.js:2314:17)
at parentElementArrayFinder.getWebElements.then (C:\portal\angular\node_modules\protractor\built\element.js:1042:27)
at ManagedPromise.invokeCallback
(C:\portal\angular\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\portal\angular\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\portal\angular\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\portal\angular\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\portal\angular\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task:
at Timeout.pollCondition [as _onTimeout] (C:\portal\angular\node_modules\selenium-webdriver\lib\promise.js:2195:19)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)

@HaHuynh2020
Copy link

HaHuynh2020 commented Apr 22, 2020

@nayanr9 I found a solution here SeleniumHQ/selenium#2888
I tried with my local fix and it's working fine in my case.

Open this file: node_modules\selenium-webdriver\http\index.js
Go to the line 238, then add the condition e.code === 'EADDRINUSE'
The new snippet should be:

 request.on('error', function(e) {
    if (e.code === 'ECONNRESET' || e.code === 'EADDRINUSE') {
      console.log(`\n!!! Got the error: ${e.code}.`);
      setTimeout(function() {
        sendRequest(options, onOk, onError, opt_data, opt_proxy);
      }, 15);
    } else {
      var message = e.message;
      if (e.code) {
        message = e.code + ' ' + message;
      }
      onError(new Error(message));
    }
  });

Hope it works...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants