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.

Missing error handler on `socket`. TypeError: (msg || "").replace is not a function Error

See original GitHub issue

I’m getting the above error when I try to run jenkins jobs using karma. Any ideas what could be causing this?

Expected behavior

karma runs angular2 tests on jenkins, they run fine on desktop.

Actual behavior

`Missing error handler on `socket`.
TypeError: (msg || "").replace is not a function
    at /home/hudson/.hudson/jobs/workspace/example/node_modules/karma/lib/reporter.js:45:23
    at onBrowserError (/home/hudson/.hudson/jobs/workspace/example/node_modules/karma/lib/reporters/base.js:58:60)
    at null.<anonymous> (/home/hudson/.hudson/jobs/workspace/example/node_modules/karma/lib/events.js:13:22)
    at emitTwo (events.js:100:13)
    at emit (events.js:185:7)
    at onKarmaError (/home/hudson/.hudson/jobs/workspace/example/node_modules/karma/lib/browser.js:95:13)
    at Socket.<anonymous> (/home/hudson/.hudson/jobs/workspace/example/node_modules/karma/lib/events.js:13:22)
    at emitOne (events.js:95:20)
    at Socket.emit (events.js:182:7)
    at Socket.onevent (/home/hudson/.hudson/jobs/workspace/example/node_modules/socket.io/lib/socket.js:335:8)
    at Socket.onpacket (/home/hudson/.hudson/jobs/workspace/example/node_modules/socket.io/lib/socket.js:295:12)
    at Client.ondecoded (/home/hudson/.hudson/jobs/workspace/example/node_modules/socket.io/lib/client.js:193:14)
    at Decoder.Emitter.emit (/home/hudson/.hudson/jobs/workspace/example/node_modules/component-emitter/index.js:134:20)
    at Decoder.add (/home/hudson/.hudson/jobs/workspace/example/node_modules/socket.io-parser/index.js:247:12)
    at Client.ondata (/home/hudson/.hudson/jobs/workspace/example/node_modules/socket.io/lib/client.js:175:18)
    at emitOne (events.js:90:13)`

Enviroment Details

  • Karma version (output of karma --version):
  • Relevant part of your karma.config.js file
  • node --version v5.7.0
  • npm --version 3.6.0 karma version 0.13.21

Steps to reproduce the behaviour

  1. run tests in jenkins, (independent of the tests running) the above stacktrace is displayed

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
randyaacommented, Jun 20, 2016

i fixed this locally by adding the following lines to karma/lib/reporter.js @ line 45:

      if ( typeof msg !== "string") {
          msg = JSON.stringify(msg);
      }

so at least there’s output

7reactions
tlefevrecommented, Mar 16, 2016

@dignifiedquire there’s still a problem to be fixed and that is the error message. It is very unhelpful and it would be very much appreciated by the community, I’m guessing, if the quality of that was improved. As shown here, the problem was a missing file. A missing file error would be much more appropriate and helpful to users.

Update: My problem was IntelliJ messing up imports in a spec. It couldn’t handle angular2 dependencies properly and gave the wrong path. Build worked fine, but testing failed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing error handler on `socket`. TypeError: (msg || "").replace is ...
I am getting following error on running unit test in angular2.I am using angular cli as build tool.Karma for unit testing.Any body can...
Read more >
Missing error handler on socket - Simon Richard Eames
Missing error handler on `socket `. TypeError: (msg || "").replace is not a function at ...
Read more >
karma-runner/karma - Gitter
I am getting the following error message. Missing error handler on socket . TypeError: (msg || "").replace is not a function
Read more >
SyntaxError: missing ) after argument list - JavaScript | MDN
The JavaScript exception "missing ) after argument list" occurs when there is an error with how a function is called. This might be...
Read more >
"TypeError: require(...).listen is not a function" in socket.io
In this video I have shown " TypeError : require(...).listen is not a function "that you might face with connecting to ...
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