karma icon indicating copy to clipboard operation
karma copied to clipboard

TypeError: Cannot read property 'mtime' of undefined

Open ghost opened this issue 8 years ago • 14 comments

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

ghost avatar Aug 03 '15 05:08 ghost

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

fbengrid avatar Aug 03 '15 05:08 fbengrid

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

ghost avatar Aug 03 '15 05:08 ghost

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

dignifiedquire avatar Aug 04 '15 09:08 dignifiedquire

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.

ghost avatar Aug 04 '15 11:08 ghost

+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

eckdanny avatar Aug 04 '15 14:08 eckdanny

+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'

cblair avatar Aug 18 '15 16:08 cblair

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

richbai90 avatar Sep 01 '15 22:09 richbai90

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

shawmanz32na avatar Sep 23 '15 00:09 shawmanz32na

Thank you @fbengrid.

donaldpipowitch avatar Sep 23 '15 05:09 donaldpipowitch

@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. :)

fbengrid avatar Sep 23 '15 06:09 fbengrid

@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.

shawmanz32na avatar Sep 24 '15 00:09 shawmanz32na

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

vladyn avatar Feb 19 '16 11:02 vladyn

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.

fbengrid avatar Feb 19 '16 17:02 fbengrid

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

mikebellcoder avatar Jan 28 '22 22:01 mikebellcoder