question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

shardTestFiles seems to result in intermittent EADDRINUSE errors

See original GitHub issue

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']);
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
HaHuynh2020commented, Apr 22, 2020

@nayanr9 I found a solution here https://github.com/seleniumhq/selenium/issues/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…

1reaction
nayanr9commented, 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.<anonymous> (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: <anonymous> 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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Error: listen EADDRINUSE while using NodeJS?
EADDRINUSE means that the port number which listen() tries to bind the server ... this error if you try to listen on port...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found