grunt-karma icon indicating copy to clipboard operation
grunt-karma copied to clipboard

Socket hang up error when trying to run in background via grunt watch

Open gunnx opened this issue 9 years ago • 4 comments

I'm trying to setup continuous testing using grunt-watch but keep getting an error 'Socket hung up'

my grunt config for karma:

karma: {
 options: {
      basePath: '',
      autoWatch: false,
      colors: true,
      frameworks: ['mocha', 'chai'],
      logLevel: 'DEBUG',
      port: 9876,
      browsers: ['PhantomJS'],
      singleRun: true
    },
    dev: {
      options: {
        port: 9877,
        background: true,
        singleRun: false
      },
      browsers: ['Chrome'],
      files: {
        src: [
          'src/js/vendor/jquery-1.11.2.min.js',
          'test/vendor/chai-jquery.js',
          'test/mocha/fixtures/**/*.fixture.html',
          'src/js/**/*.js',
          'test/mocha/lib/*.js',
          'test/mocha/**/*.js'
        ]
      },
      preprocessors: {
        'test/mocha/fixtures/**/*.fixture.html': ['html2js']
      },
      reporters: ['nyan']
  }
}

my grunt watch task

karma: {
    files: ['src/js/module/**/*.js', 'test/mocha/**/*.spec.js'],
    tasks: ['karma:dev:run']
  },

I test by running grunt karma:dev:start watch:karma I can see the process running and blocking. If I then edit a file it runs the karma:dev:run task but this throws an error:

output:

$ grunt karma:dev:start watch:karma
Running "karma:dev:start" (karma) task

Running "watch:karma" (watch) task
Waiting...
>> File "test/mocha/calculator.spec.js" changed.
Running "karma:dev:run" (karma) task
[2015-04-16 16:39:39.040] [DEBUG] config - No config file specified.
>> Error
Fatal error: socket hang up

using grunt-karma 0.10.1 and karma 0.12.31 and grunt-watch 0.6.1

gunnx avatar Apr 16 '15 15:04 gunnx

I'm experiencing the same thing.

31 07 2015 16:58:00.937:WARN [proxy]: failed to proxy /w/load.php?modules=jquery%2Cmediawiki&only=scriptsversion=woIh%2FgTQ
 (socket hang up)
31 07 2015 16:58:00.937:WARN [proxy]: failed to proxy /w/load.php?modules=jquery%2Cmediawiki&only=scriptsversion=woIh%2FgTQ
 (socket hang up)
31 07 2015 16:58:00.937:WARN [proxy]: failed to proxy /w/load.php?modules=jquery%2Cmediawiki&only=scriptsversion=woIh%2FgTQ
 (socket hang up)
        karma: {
            options: {
                proxies: { "/w": "http://mediawiki.dev/w" }

Krinkle avatar Aug 01 '15 00:08 Krinkle

Hi @Krinkle, I know this is an old thread, but just for your and other proxies users' information: If you don't provide proxy target URL with a port number, it gets default karma port (in default case: 9876). This results in DEBUG [proxy]: [39mproxying request - <proxied_file> to <target_url>:9876 Correcting this to 80 (http) or 443 (https) solved the problem for me.

mianowski avatar Mar 11 '16 15:03 mianowski

Hi @Krinkle, I also know that this is an old thread ;) I had the same issue and figured out that I have ciruclar proxies -> My proxies were using them selves.

In my case /base/app has been extracted to a proxy, eg. "/app". The target URLs were using "/app/.../..." which caused that /app was called in an endless loop -> socket hang up

ilkercat avatar Apr 12 '16 09:04 ilkercat

@ilkercat @mianowski This bug is now fixed. See https://github.com/karma-runner/karma/issues/1987.

Krinkle avatar Apr 12 '16 19:04 Krinkle