karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

TypeError: Cannot read property 'mtime' of undefined #1532

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi, my users get this error on Mac OS X with Karma 0.13.2. It's this line: https://github.com/karma-runner/karma/blob/v0.13.2/lib/file-list.js#L174 where mg.statCache[path] is undefined. Here is the Karma config that is used https://gist.github.com/Sanjo/fde7bf14768d6baf16e6.

Maybe related to https://github.com/karma-runner/karma/issues/1494.

/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/file-list.js:174
      var mtime = mg.statCache[path].mtime
                                    ^
TypeError: Cannot read property 'mtime' of undefined
  at /Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/file-list.js:174:37
  at Array.map (native)
  at Promise.all.cancellable.then.self.buckets (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/file-list.js:168:30)
  at Array.map (native)
  at [object Object].List._refresh (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/file-list.js:151:37)
  at [object Object].List.refresh (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/file-list.js:250:27)
  at [object Object].Server._start (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/server.js:168:12)
  at [object Object].invoke (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/node_modules/di/lib/injector.js:75:15)
  at [object Object].Server.start (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/server.js:92:18)
  at Object.exports.run (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/lib/cli.js:231:26)
  at Object.<anonymous> (/Users/Dimitri/.meteor/packages/sanjo_karma/.1.6.1.6961j1++os.osx.x86_64+web.browser+web.cordova/npm/node_modules/karma/bin/karma:3:23)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:929:3
fbengrid commented 9 years ago

I had the same issue but solved it by changing all the file groups patterns ending from *.{a,b,c} to *.+(a|b|c)

ghost commented 9 years ago

Ok, thanks. :+1: I will do that.

dignifiedquire commented 9 years ago

Interesting, that this happens on non windows systems as well, this is mainly due to an issue in node-glob. Will have to do more digging. Thanks for the report

ghost commented 9 years ago

One of my package users reported that changing the glob patterns from *.{a,b,c} to *.+(a|b|c) fixed the problem as @fbengrid pointed out.

eckdanny commented 9 years ago

+1 for @fbengrid's workaround (i'm on a mac)

Error snippet:

/path/to/node_modules/karma/lib/file-list.js:174
      var mtime = mg.statCache[path].mtime
                                    ^
TypeError: Cannot read property 'mtime' of undefined
...

My Env:

$sw_vers
ProductName:    Mac OS X
ProductVersion: 10.10.4
BuildVersion:   14E46
$node_modules/.bin/karma --version
Karma version: 0.13.4
karma-jasmine: 0.3.6
karma-phantomjs-launcher: 0.2.0
cblair commented 9 years ago

+1 I have this issue fairly regularly on Ubuntu 14.04, using PyCharm 4.5 and the latest Karma plugin. karma package version 0.12.37:

ERROR [karma]: [TypeError: Cannot read property 'mtime' of undefined]
TypeError: Cannot read property 'mtime' of undefined
  at /mnt/colbblailx.old/home/colbblai/src/sel2730S/nucleus/core/omni/SettingsClasses/list/node_modules/karma/lib/file_list.js:317:31
  at Object.oncomplete (fs.js:108:15)

Haven't found what causes it exactly, happens intermittently. I do get errors just before it, which may be related. But again are related to something the karma runner is doing with .ktp.ts files, not sure why they're failing:

INFO [watcher]: Removed file "/.../src/cert.ts.ktp.ts".
WARN [watcher]: { [Error: ENOENT, stat '/.../src/cert.ts.ktp.ts']
  errno: 34,
  code: 'ENOENT',
  path: '/.../src/cert.ts.ktp.ts' }
Error: ENOENT, stat '/.../src/cert.ts.ktp.ts'
richbai90 commented 9 years ago

I'm having this same issue and I can't find where to change the glob patterns. I'm on OS X Yosemite.

node version 0.12.1 karma version 0.13.9

shawmanz32na commented 9 years ago

It may be of interest to note that on one of the projects I'm working on, we had a dev perform the workaround mentioned by @fbengrid , which subsequently resulted in a WARN [watcher]: Pattern "C:/Users/username/project/src/main/webapp/scripts/components/**/*.{js|html}" does not match any file. message and an entire suite of broken tests on my Windows box due to the angular injector not having the required files.

You might want to verify that the fix works cross-platform before patching in the suggested workaround.

I'm using: Windows 10 Node 0.12.7 Karma 0.12.35

donaldpipowitch commented 9 years ago

Thank you @fbengrid.

fbengrid commented 9 years ago

@shawmanz32na I do work mainly with windows environment (for the dev phase at least) but not on windows 10. Just to be sure looking at the pattern you wrote and the one I was referring to for the "glob" to work on karma 0.13.x, it must use parenthesis not accolades: so *.+(js|html) and not *.{js|html} Using accolades will not work for recent version of karma (last I worked with was 0.13.9).

@donaldpipowitch you're welcome, but it's the authors of this library who deserve our thanks for this great tool. :)

shawmanz32na commented 9 years ago

@fbengrid We changed our glob pattern to *.+(js|html) and all is well. Thanks for the clarification. We missed the part about changing the accolades to parens the first time around.

vladyn commented 8 years ago

Which conf file you referring? Can you paste the example please ?

fbengrid commented 8 years ago

the configuration file referred to is the one presented on http://karma-runner.github.io/0.13/config/configuration-file.html and the patterns is the one used for the File attribute.

mikebellcoder commented 2 years ago

Just ran into this yesterday and comment from earlier fixed it for me. https://github.com/karma-runner/karma/issues/1532#issuecomment-127128326