Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestError: connect ECONNREFUSED 127.0.0.1:9515 #862

Open
jeffcrouse opened this issue Feb 15, 2021 · 5 comments
Open

RequestError: connect ECONNREFUSED 127.0.0.1:9515 #862

jeffcrouse opened this issue Feb 15, 2021 · 5 comments

Comments

@jeffcrouse
Copy link

I suddenly started getting this error in some mocha tests that had been running just fine. The code is something like this:

var link = this.app.client.$('#blah')
await link.waitForExist({ timeout: 30000 });
await link.click();

and the full error is

RequestError: socket hang up
    at ClientRequest.<anonymous> (/Users/[redacted]/node_modules/webdriver/node_modules/got/dist/source/core/index.js:953:111)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:327:22)
    at ClientRequest.EventEmitter.emit (domain.js:467:12)
    at ClientRequest.origin.emit (/Users/[redacted]/node_modules/webdriver/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
    at Socket.socketOnEnd (_http_client.js:493:9)
    at Socket.emit (events.js:327:22)
    at Socket.EventEmitter.emit (domain.js:467:12)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at connResetException (internal/errors.js:607:14)
    at Socket.socketOnEnd (_http_client.js:493:23)
    at Socket.emit (events.js:327:22)
    at Socket.EventEmitter.emit (domain.js:467:12)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

I put some logging in and it seems to be happening on the first line, which is weird because I use the exact same syntax in a previous test and it works just fine. I have double-checked that #blah does, in fact, exist in the DOM. My instinct is that something I did is causing the socket to hang up, but the "socket hang up" message is the only hint I have.

This same error occurs on both Mac and Windows. I am using Spectron ^11.1.0 with Electron ^9.1.1.

Elsewhere (in the Webdriver issues, I think) I have found something about a problem with the version of "got" that is used, but I didn't have any luck going down that road.

I can't, for the life of me, find anything in a diff that would have caused this.

Thanks in advance for any help.

@sytolk
Copy link

sytolk commented Feb 25, 2021

The same error in github actions platform Windows this happened after update spectron from v12 to v13

github-actions
/ Jest Report Electron
TST04 - Testing the tag library: > TST0404 - Change default tag group tag colors [web,minio,electron]
RequestError: connect ECONNREFUSED 127.0.0.1:9515


Stacktrace:
    at ClientRequest.<anonymous> (node_modules\webdriver\node_modules\got\dist\source\core\index.js:940:25)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.EventEmitter.emit (domain.js:483:12)
    at ClientRequest.origin.emit (node_modules\webdriver\node_modules\@szmarczak\http-timer\dist\source\index.js:39:20)
    at Socket.socketErrorListener (_http_client.js:427:9)
    at Socket.emit (events.js:314:20)
    at Socket.EventEmitter.emit (domain.js:483:12)
    at emitErrorNT (internal\streams\destroy.js:92:8)
    at emitErrorAndCloseNT (internal\streams\destroy.js:60:3)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)

but I think that error is comming from WDIO updates in new spectron.
[email protected] -> [email protected]
spectron@^12.0.0 -> spectron@^13.0.0
[email protected] -> [email protected]
webdriverio@^6.1.20 -> webdriverio@^6.9.1

Its have the same error in the same test testing with wdio without spectron.

github-actions
/ Jest Report Web
TST04 - Testing the tag library: > TST0404 - Change default tag group tag colors [web,minio,electron]
RequestError: connect ECONNREFUSED 127.0.0.1:9515


Stacktrace:
    at ClientRequest.<anonymous> (node_modules\webdriver\node_modules\got\dist\source\core\index.js:940:25)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.EventEmitter.emit (domain.js:483:12)
    at ClientRequest.origin.emit (node_modules\webdriver\node_modules\@szmarczak\http-timer\dist\source\index.js:39:20)
    at Socket.socketErrorListener (_http_client.js:427:9)
    at Socket.emit (events.js:314:20)
    at Socket.EventEmitter.emit (domain.js:483:12)
    at emitErrorNT (internal\streams\destroy.js:92:8)
    at emitErrorAndCloseNT (internal\streams\destroy.js:60:3)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)

@evertonlperes
Copy link

I can reproduce the same error on my app.
There's just a small characteristic on my app where it will detect it if the first time that the app will be opened (setup some configs) and them it will close the config page and open the main page.

I'm struggling to make it pass without getting the RequestError: connect ECONNREFUSED 127.0.0.1:9515

Here's my spec file:

import path from 'path';
import os from 'os';
import { Application, SpectronClient } from 'spectron';
import { BrowserWindow } from 'electron';
import NavBarPage from './pages/navbar';
import FirstRunPage from './pages/firstrun';
import * as TestUtils from './utils/TestUtils';

const electronPath = require('electron');

TestUtils.setupJestTimeout();

let app: Application;
let client: SpectronClient;
let browserWindow: BrowserWindow;
let navBarPage: NavBarPage;
let firstRunPage: FirstRunPage;

beforeAll(async() => {
  app = new Application({
    path:             electronPath as any,
    args:             [path.dirname(__dirname)],
    chromeDriverArgs: [
      '--no-sandbox',
      '--whitelisted-ips=',
      '--disable-dev-shm-usage',
    ],
    webdriverLogPath: './',
  });

  await app.start();
  client = app.client;
  browserWindow = app.browserWindow;
  navBarPage = new NavBarPage(app);
  firstRunPage = new FirstRunPage(app);
});

beforeEach(async() => {
  await app.client.waitUntilWindowLoaded();
});

afterAll(async() => {
  if (app && app.isRunning()) {
    await app.stop();
  }
});

describe('Test App Desktop - Fist Run', () => {
  if (process.env.CI) {
    it('should open settings page - First Run', async() => {
      const k8sSettings = await firstRunPage.getK8sVersionHeaderText();
      const acceptBtnSelector = '[data-test="accept-btn"]';

      expect(k8sSettings).toBe('Welcome to App Desktop');

      (await client.$(acceptBtnSelector)).waitForExist();
      (await client.$(acceptBtnSelector)).click();
    });
  } else {
    it('should open General the main window', async() => {
      const title = await browserWindow.getTitle();

      expect(title).toBe('App Desktop');
    });
  }
});

describe('App Desktop - Main Pages', () => {
  it('should display welcome message in general tab', async() => {
    const title = await browserWindow.getTitle();

    await client.waitUntilTextExists(title, 'App Desktop', 10000);
    const generalPage = await navBarPage.getGeneralPage();

    expect(generalPage).not.toBeNull();
    expect(await generalPage?.getTitle()).toBe('Welcome to App Desktop');
  });
});

Versions:

Spectron: v14.0.0
Electron: v12.0.18
jest: v24.9.0
webdriverio: v6.9.1

Any insights will be very appreciated.

@Shirisha8812
Copy link

I am also facing the same issue.
My webdriver version is 6.0.1
I added chrome capabilities as
goog:chromeOptions': {
args: [ '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage --window-size=1920,1080', '--disable-translate', '--disable-extensions', '--disable-background-networking', '--disable-sync', '--disable-default-apps', '--mute-audio', '--no-first-run', '--disable-prompt-on-repost']
}

Any help is appreciated. Thanks

@evertonlperes
Copy link

I am also facing the same issue.

My webdriver version is 6.0.1

I added chrome capabilities as

goog:chromeOptions': {

        args: [ '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage --window-size=1920,1080', '--disable-translate', '--disable-extensions', '--disable-background-networking', '--disable-sync', '--disable-default-apps', '--mute-audio', '--no-first-run', '--disable-prompt-on-repost']

    }

Any help is appreciated. Thanks

My 2 cents... move to Playwright.
I didn't face any of those weird Chrome issue after refactoring and implementes Playwright.

@bhadmus
Copy link

bhadmus commented Feb 16, 2023

A node change did it for me, I installed v16.14.0 via nvm and also downgraded appium to 2.0.0-beta.46 and it worked

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

No branches or pull requests

5 participants