Webpack: [karma]: TypeError: Cannot read property 'unmask' of undefined

Created on 26 May 2017  路  9Comments  路  Source: vuejs-templates/webpack

Hello! I just started new project with vue-webpack template and get this error when start Karma.

My configuration is
OS: linux
nodejs 7.10.0

Thanks!

[email protected] test:watch /home/alexey2baranov/htdocs/terminal-client
cross-env BABEL_ENV=test karma start test/unit/karma.conf.js

26 05 2017 11:20:27.635:WARN [karma]: No captured browser, open http://localhost:9876/
26 05 2017 11:20:27.813:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
26 05 2017 11:20:27.816:INFO [launcher]: Launching browser Chrome with unlimited concurrency
26 05 2017 11:20:31.222:INFO [launcher]: Starting browser Chrome
26 05 2017 11:20:36.924:INFO [Chrome 57.0.2987 (Linux 0.0.0)]: Connected on socket CPDfri4jMAa3b6CEAAAA with id 12770951
26 05 2017 11:20:36.933:ERROR [karma]: TypeError: Cannot read property 'unmask' of undefined
at Receiver.unmask (/home/alexey2baranov/htdocs/terminal-client/node_modules/engine.io/node_modules/ws/lib/Receiver.js:306:46)
at Receiver.finish (/home/alexey2baranov/htdocs/terminal-client/node_modules/engine.io/node_modules/ws/lib/Receiver.js:505:25)
at Receiver.expectHandler (/home/alexey2baranov/htdocs/terminal-client/node_modules/engine.io/node_modules/ws/lib/Receiver.js:493:33)
at Receiver.add (/home/alexey2baranov/htdocs/terminal-client/node_modules/engine.io/node_modules/ws/lib/Receiver.js:103:24)
at Socket.realHandler (/home/alexey2baranov/htdocs/terminal-client/node_modules/engine.io/node_modules/ws/lib/WebSocket.js:825:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at Socket.Readable.push (_stream_readable.js:136:10)
at TCP.onread (net.js:561:20)

package.json

{
  "name": "terminal-client",
  "version": "1.0.0",
  "description": "terminal clietn",
  "author": "[email protected]",
  "private": true,
  "scripts": {
    "crossbar": "crossbar start",
    "dev": "node build/dev-server.js",
    "build": "node build/build.js",
    "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
    "test": "npm run unit",
    "test:watch": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js"
  },
  "dependencies": {
    "autobahn": "^17.5.2",
    "bootstrap": "^3.3.7",
    "event-emitter": "^0.3.5",
    "jquery": "^3.2.1",
    "loglevel": "^1.4.1",
    "tether": "^1.4.0",
    "vue": "^2.2.2"
  },
  "devDependencies": {
    "autoprefixer": "^6.7.2",
    "babel-core": "^6.22.1",
    "babel-loader": "^6.2.10",
    "babel-plugin-istanbul": "^3.1.2",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-preset-env": "^1.2.1",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chai": "^3.5.0",
    "chalk": "^1.1.3",
    "connect-history-api-fallback": "^1.3.0",
    "copy-webpack-plugin": "^4.0.1",
    "cross-env": "^3.2.4",
    "css-loader": "^0.26.1",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.14.1",
    "extract-text-webpack-plugin": "^2.0.0",
    "file-loader": "^0.10.0",
    "friendly-errors-webpack-plugin": "^1.1.3",
    "function-bind": "^1.1.0",
    "html-webpack-plugin": "^2.28.0",
    "http-proxy-middleware": "^0.17.3",
    "inject-loader": "^2.0.1",
    "karma": "^1.4.1",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-mocha": "^1.3.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-sinon-chai": "^1.2.4",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-spec-reporter": "0.0.26",
    "karma-webpack": "^2.0.2",
    "lolex": "^1.5.2",
    "mocha": "^3.2.0",
    "opn": "^4.0.2",
    "optimize-css-assets-webpack-plugin": "^1.3.0",
    "ora": "^1.1.0",
    "phantomjs-prebuilt": "^2.1.14",
    "rimraf": "^2.6.0",
    "semver": "^5.3.0",
    "sinon": "^1.17.7",
    "sinon-chai": "^2.8.0",
    "url-loader": "^0.5.7",
    "vue-loader": "^11.1.4",
    "vue-style-loader": "^2.0.0",
    "vue-template-compiler": "^2.2.4",
    "webpack": "^2.2.1",
    "webpack-bundle-analyzer": "^2.2.1",
    "webpack-dev-middleware": "^1.10.0",
    "webpack-hot-middleware": "^2.16.1",
    "webpack-merge": "^2.6.1"
  },
  "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

Most helpful comment

If you remove autobahn from your project, npm run test won't fail anymore.

All 9 comments

I got the same error with autobahn. I think it's related to https://github.com/websockets/ws/issues/1010 but I didn't succeed to resolve the problem.

Anyway, we probably won't find an answer here. This issue can be closed.

It works fine after
npm run dev
npm run build

But crashes after
npm run test

So i think this issue relates to karma, but not to ws or autobahn

If you remove autobahn from your project, npm run test won't fail anymore.

Why karma can't start autobahn? Autobahn don't know about karma anything so we should not ask him from my point of view.

My guess is karma has issues with websockets as you can see here : https://github.com/websockets/ws/issues/1010 & https://github.com/karma-runner/karma/issues/2593

I just had this error today and didn't have time to investigate further.

Maybe this related with new nodejs. I had this issue first time after node 7.7.2->7.10.0 upgrade.

A workaround that works for me:

remove old node_modules/
run npm install --no-optional

seems resolved in karma.

Was this page helpful?
0 / 5 - 0 ratings