Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just updated to .13, Cannot read property 'mtime' of undefined #1494

Closed
ghost opened this issue Jul 15, 2015 · 48 comments · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132
Closed

Comments

@ghost
Copy link

ghost commented Jul 15, 2015

5:38:03] TypeError: Cannot read property 'mtime' of undefined
    at c:\git\pos\node_modules\karma\lib\file-list.js:173:37
    at Array.map (native)
    at c:\git\pos\node_modules\karma\lib\file-list.js:167:30
    at Array.map (native)
    at List._refresh (c:\git\pos\node_modules\karma\lib\file-list.js:150:37)
    at List.refresh (c:\git\pos\node_modules\karma\lib\file-list.js:249:27)
    at Server._start (c:\git\pos\node_modules\karma\lib\server.js:149:12)
    at invoke (c:\git\pos\node_modules\karma\node_modules\di\lib\injector.js:75:15)
    at Server.start (c:\git\pos\node_modules\karma\lib\server.js:91:18)
    at runTests (c:\git\pos\gulpfile.js:684:11)
    at c:\git\pos\gulpfile.js:714:6
    at bound (domain.js:254:14)
    at runBound (domain.js:267:12)
    at asyncRunner (c:\git\pos\node_modules\gulp\node_modules\undertaker\node_modules\bach\node_modules\async-done\index.js:38:18)
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
@dignifiedquire
Copy link
Member

Thanks for the report, I will try to fix it in the morning

@dignifiedquire
Copy link
Member

What version of node are you running?

@ghost
Copy link
Author

ghost commented Jul 16, 2015

0.12.7

@ghost
Copy link
Author

ghost commented Jul 16, 2015

for some reason karma-jasmine's new version number is lower than the old one! 0.1.6 is < 0.3.6 so NPM favored the newer one.

Does this work with the latest (assuming 0.3.6)

@dignifiedquire
Copy link
Member

There was an issue with the tagging of karma-jasmine, as there are two versions, the 0.1.x branch, which supports jasmine 1 and the 0.3.x branch which supports jasmine 2.
I fixed that last night though.

@dignifiedquire
Copy link
Member

@robertbaker I just tested things, and it seems to work fine for me, could you create a small project that reproduces this error please?

@jonnenauha
Copy link

I'm also getting this error once I updated to karma 0.13.0 karma-jasmine 0.3.6. I'm using grunt-karma as well, it just updated to 0.12.0 that fixes the new Server bug.

On top of that im using requirejs in the tests. I have a version that test with and without requirejs. If I dont run the requirejs tests this error does not occur. @robertbaker are you using requirejs in your tests? If i comment out the requirejs plugin from frameworks: ['jasmine', 'requirejs', 'detectBrowsers'], this error does not print but ofc later errors our as require/define functions are not defined.

I checked and the karma-requirejs has been updated last time a year ago. I doubt there are big changes and the internals seem pretty simple. I am using requirejs 2.1.19, is it possible there is some breakage there. karma-requirejs does not seem to import its own requirejs.

Not sure what to think about this tbh, i cant find the 'mtime' error line, havent tried a node debugger yet, not even sure I can run it with my grunt build command that runs the karma tests via grunt.

@dignifiedquire
Copy link
Member

The relevant line is this https://github.com/karma-runner/karma/blob/master/lib/file-list.js#L173 my guess is that the pattern that is checked in the glob isn't found. As requirejs does some strange things when it comes to imports I could imagine that somewhere around there it fails.

@dignifiedquire
Copy link
Member

But this simple requirejs example in our integration tests works fine: https://github.com/karma-runner/integration-tests/tree/master/requirejs

@dignifiedquire
Copy link
Member

@jonnenauha what os are you running on?

@dignifiedquire dignifiedquire modified the milestone: 0.13.1 Jul 16, 2015
@jonnenauha
Copy link

Win8.1 64bit, node v0.12.5, npm 2.11.2

If anyone else bumps to this until is resolved, I just forced my package.json to the old version. What was missing was forcing karma itself to 0.12.x, if not done something else in the chain was pulling in 0.13 with ^0.12. I'm no node/npm expert but looks like that happened :)

Force old version(s) with in package.json

"grunt-karma": "=0.11.1",
"karma" : "=0.12.37",
"karma-jasmine": "=0.3.5", // not sure if strictly needed

@dignifiedquire
Copy link
Member

Thanks @jonnenauha it looks like this has to do something with windows :( I will see what I can find out

@SomethingSexy
Copy link

@dignifiedquire just to give you some more information in case it is helpful. I am running Win7, node v0.10.30 and npm1.4.21

@SomethingSexy
Copy link

@jonnenauha I was able to run off of karma-jasmine 0.3.6

@dignifiedquire
Copy link
Member

Could one of you please post a full log output with log level set to DEBUG please?

@SomethingSexy
Copy link

16 07 2015 10:19:25.224:DEBUG [plugin]: Loading karma-* from D:\development\proj
ects\ui-tbone\node_modules
16 07 2015 10:19:25.226:DEBUG [plugin]: Loading plugin D:\development\projects\u
i-tbone\node_modules/karma-chrome-launcher.
16 07 2015 10:19:25.232:DEBUG [plugin]: Loading plugin D:\development\projects\u
i-tbone\node_modules/karma-coverage.
16 07 2015 10:19:25.435:DEBUG [plugin]: Loading plugin D:\development\projects\u
i-tbone\node_modules/karma-jasmine.
16 07 2015 10:19:25.437:DEBUG [plugin]: Loading plugin D:\development\projects\u
i-tbone\node_modules/karma-phantomjs-launcher.
16 07 2015 10:19:25.461:DEBUG [plugin]: Loading plugin D:\development\projects\u
i-tbone\node_modules/karma-qunit.
16 07 2015 10:19:25.463:DEBUG [plugin]: Loading plugin D:\development\projects\u
i-tbone\node_modules/karma-requirejs.

D:\development\projects\ui-tbone\node_modules\karma\lib\file-list.js:173
      var mtime = mg.statCache[path].mtime
                                    ^
TypeError: Cannot read property 'mtime' of undefined
    at D:\development\projects\ui-tbone\node_modules\karma\lib\file-list.js:173:
37
    at Array.map (native)
    at Promise.all.cancellable.then.self.buckets (D:\development\projects\ui-tbo
ne\node_modules\karma\lib\file-list.js:167:30)
    at Array.map (native)
    at List._refresh (D:\development\projects\ui-tbone\node_modules\karma\lib\fi
le-list.js:150:37)
    at List.refresh (D:\development\projects\ui-tbone\node_modules\karma\lib\fil
e-list.js:249:27)
    at Server._start (D:\development\projects\ui-tbone\node_modules\karma\lib\se
rver.js:149:12)
    at invoke (D:\development\projects\ui-tbone\node_modules\karma\node_modules\
di\lib\injector.js:75:15)
    at Server.start (D:\development\projects\ui-tbone\node_modules\karma\lib\ser
ver.js:91:18)
    at Object.exports.run (D:\development\projects\ui-tbone\node_modules\karma\l
ib\cli.js:222:26)
    at requireCliAndRun (C:\Users\tcvetan\AppData\Roaming\npm\node_modules\karma
-cli\bin\karma:44:16)
    at C:\Users\tcvetan\AppData\Roaming\npm\node_modules\karma-cli\bin\karma:54:
12
    at C:\Users\tcvetan\AppData\Roaming\npm\node_modules\karma-cli\node_modules\
resolve\lib\async.js:44:21
    at ondir (C:\Users\tcvetan\AppData\Roaming\npm\node_modules\karma-cli\node_m
odules\resolve\lib\async.js:187:31)
    at C:\Users\tcvetan\AppData\Roaming\npm\node_modules\karma-cli\node_modules\
resolve\lib\async.js:153:39
    at onex (C:\Users\tcvetan\AppData\Roaming\npm\node_modules\karma-cli\node_mo
dules\resolve\lib\async.js:93:22)

@jonnenauha
Copy link

Here is mine

$ grunt -v --debug --stack build

.. lots of  (hopefully) unrelated build steps ...

Running "karma:test_unit_browsers" (karma) task
[D] Task source: c:\<my-git-repo>\node_modules\grunt-karma\tasks\grunt-karma.js
Verifying property karma.test_unit_browsers exists in config...OK
File: [no files]
Options: background=false, client={}, configFile="karma.conf.js", browsers=["PhantomJS"], singleRun
16 07 2015 18:18:29.819:INFO [framework.detect-browsers]: Following browsers where detected on your system: [ 'Chrome', 'Firefox', 'IE', 'PhantomJS' ]
Warning: Cannot read property 'mtime' of undefined Use --force to continue.
TypeError: Cannot read property 'mtime' of undefined
    at c:\<my-git-repo>\node_modules\karma\lib\file-list.js:173:37
    at Array.map (native)
    at c:\<my-git-repo>\node_modules\karma\lib\file-list.js:167:30
    at Array.map (native)
    at List._refresh (c:\<my-git-repo>\node_modules\karma\lib\file-list.js:150:37)
    at List.refresh (c:\<my-git-repo>\node_modules\karma\lib\file-list.js:249:27)
    at Server._start (c:\<my-git-repo>\node_modules\karma\lib\server.js:149:12)
    at invoke (c:\<my-git-repo>\node_modules\karma\node_modules\di\lib\injector.js:75:15)
    at Server.start (c:\<my-git-repo>\node_modules\karma\lib\server.js:91:18)
    at Object.<anonymous> (c:\<my-git-repo>\node_modules\grunt-karma\tasks\grunt-karma.js:133:14)
    at Object.<anonymous> (c:\<my-git-repo>\node_modules\grunt\lib\grunt\task.js:264:15)
    at Object.thisTask.fn (c:\<my-git-repo>\node_modules\grunt\lib\grunt\task.js:82:16)
    at Object.<anonymous> (c:\<my-git-repo>\node_modules\grunt\lib\util\task.js:301:30)
    at Task.runTaskFn (c:\<my-git-repo>\node_modules\grunt\lib\util\task.js:251:24)
    at Task.<anonymous> (c:\<my-git-repo>\node_modules\grunt\lib\util\task.js:300:12)
    at c:\<my-git-repo>\node_modules\grunt\lib\util\task.js:227:11

Aborted due to warnings.

Does looks like you were right. I havent changed the glob strings in a long time. Here is what they look like, I changed the folder names as its a private repo, hope it clarifies anyways :) From karma.conf.js

// list of files / patterns to load in the browser
files: [
  'test/test-main.js',
  {pattern: 'src/folder1/**/*.js', included: false},
  {pattern: 'src/folder2/*.js', included: false},
  {pattern: 'src/folder3/**/*.js', included: false},
  {pattern: 'src/folder4/**/*.js', included: false},
  {pattern: 'test/spec/*.js', included: false}
],

@ghost
Copy link
Author

ghost commented Jul 16, 2015

I'm on 8.1 x64.

@dignifiedquire
Copy link
Member

I was finally able to reproduce this, it seems it's a combination of requirejs + karma@0.13 + windows

@ghost
Copy link
Author

ghost commented Jul 16, 2015

@dignifiedquire I'm not using requirejs. However I am using karma-jspm (trying karma-systemjs atm).

My JS is transpiled typescript to ES6.

@dignifiedquire
Copy link
Member

Thanks @robertbaker I found the issue, I hope to be pushing a fix out tonight

@dignifiedquire
Copy link
Member

@jonnenauha also when I have the fix ready I will cut 0.13.1 anyway tonight hopefully, so you don't need to jump through those hoops

dignifiedquire added a commit that referenced this issue Jul 16, 2015
Normalize glob patterns before they are passed to
node-glob to avoid issues on windows, where the resolved
files and the statCache entries do not match.

Closes #1494
@dignifiedquire
Copy link
Member

Fix was released in 0.13.1

@jonnenauha
Copy link

Can verify this fixed my issue. Thanks.

"grunt-karma": "=0.12.0", // This gets karma ^0.12.0 so the latest 0.13.1
"karma-jasmine": "=0.3.6",
"karma-requirejs": "^0.2.2",

@fbengrid
Copy link

hiya,
It seems this error is still present if you add a pattern like this in the file list to filter the files extensions:

{ pattern: 'src/main/js/**/*.{js,html,css}', included: false}

Regards.

@dignifiedquire
Copy link
Member

@fbengrid could you provide more details? For me this is working fine

@fbengrid
Copy link

@dignifiedquire sure

I don't use requirejs but have my own adapter for the dojo toolkit with its AMD loader.
Saying this, it shouldn't matter as i would get the issue straight away and it breaks karma before the web server is started.

The environment is windows.
karma 0.13.1
The following pattern

{ pattern: 'src/main/js/**/*.{js,html,css}', included: false}

breaks karma with the following stack trace:

17 07 2015 15:23:40.958:DEBUG [plugin]: Loading karma-* from c:\Java\project\dojo\grid\node_modules
17 07 2015 15:23:40.960:DEBUG [plugin]: Loading plugin c:\Java\project\dojo\grid\node_modules/karma-chrome-launcher.
17 07 2015 15:23:40.975:DEBUG [plugin]: Loading plugin c:\Java\project\dojo\grid\node_modules/karma-coverage.
17 07 2015 15:23:41.354:DEBUG [plugin]: Loading plugin c:\Java\project\dojo\grid\node_modules/karma-dhtml-reporter.
17 07 2015 15:23:41.829:DEBUG [plugin]: Loading plugin c:\Java\project\dojo\grid\node_modules/karma-firefox-launcher.
17 07 2015 15:23:41.832:DEBUG [plugin]: Loading plugin c:\Java\project\dojo\grid\node_modules/karma-ie-launcher.
17 07 2015 15:23:41.863:DEBUG [plugin]: Loading plugin c:\Java\project\dojo\grid\node_modules/karma-jasmine.
17 07 2015 15:23:41.865:DEBUG [plugin]: Loading plugin c:\Java\project\dojo\grid\node_modules/karma-mocha-reporter.

c:\Java\project\dojo\grid\node_modules\karma\lib\file-list.js:174
      var mtime = mg.statCache[path].mtime
                                    ^
TypeError: Cannot read property 'mtime' of undefined
    at c:\Java\project\dojo\grid\node_modules\karma\lib\file-list.js:174:37
    at Array.map (native)
    at c:\Java\project\dojo\grid\node_modules\karma\lib\file-list.js:168:30
    at Array.map (native)
    at List._refresh (c:\Java\project\dojo\grid\node_modules\karma\lib\file-list.js:151:37)
    at List.refresh (c:\Java\project\dojo\grid\node_modules\karma\lib\file-list.js:250:27)
    at Server._start (c:\Java\project\dojo\grid\node_modules\karma\lib\server.js:149:12)
    at invoke (c:\Java\project\dojo\grid\node_modules\karma\node_modules\di\lib\injector.js:75:15)
    at Server.start (c:\Java\project\dojo\grid\node_modules\karma\lib\server.js:91:18)
    at Object.exports.run (c:\Java\project\dojo\grid\node_modules\karma\lib\cli.js:222:26)
    at Object.<anonymous> (c:\Java\project\dojo\grid\node_modules\karma\bin\karma:3:23)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

To resolve the issue and have it working as it was with karma 0.12.x I would need to replace the patterns with the following one:

{ pattern: 'src/main/js/**/*.js', included: false},
{ pattern: 'src/main/js/**/*.html', included: false},
{ pattern: 'src/main/js/**/*.css', included: false},

so splitting the filters works as before, but the grouping them based on the files extension doesn't anymore :(

Not sure if you need more information ?
regards

EDIT:
forgot to add: node version is 0.12.6

@dignifiedquire
Copy link
Member

I can't reproduce this with the pattern structure you are describing above. Could I see the adapter code you are using, as my guess is that the issue is related to something in there

@fbengrid
Copy link

@dignifiedquire sure, i would be surprised if that was the issue since the only thing which has changed is the version of karma.

var dojoConfig = {

    // base url containing our JS files
    baseUrl: '',

    // packages declaration for dojo
    packages: [ { name: "dojo", location: "/dojo" },
                { name: "dijit", location: "/dijit" },
                { name: "grid", location: "/grid" }],

    // Indicates that dojo core should be loaded asynchronously
    async: true,

    // amount of time to wait before signaling load timeout for a module
    waitSeconds: 30,

    // append a time to each module url query to avoid module caching
    cacheBust: true,

    isDebug: true,

    // will contain all the dependencies to be loaded immediately once Dojo has loaded
    deps: [],

    // the callback to execute when all the deps have been loaded
    callback: null
};

(function(karma){

    // Jasmine will start karma when it's loaded, which we don't want since
    // Karma need to be started only after all the specs and their dependencies have been loaded
    // by the dojo loader.
    karma.loaded = function() {};

    // add all the registered the Specs to be loaded by dojo along their dependencies
    for (var file in karma.files) {
        if (/Spec\.js$/i.test(file)) {
            dojoConfig.deps.push(file);
        }
    }

    // notify Karma when dojo is ready and that the deps have been loaded
    dojoConfig.callback = function() {
        //console.log('dojo deps loaded');
        karma.start();
    };

    //console.log(dojoConfig);

})(window.__karma__);

@dignifiedquire
Copy link
Member

Okay, the adapter seems to have nothing to do with it.

Could you do me a big favor and add in your karma version manually the following line onto https://github.com/karma-runner/karma/blob/master/lib/file-list.js#L173

log.debug('Fetching cache', pattern, path)
log.debug('Resolved', Object.keys(mg.statCache))

and then run with log level set to DEBUG and paste me the output, thanks

@fbengrid
Copy link

Sending you the logs by email (too big to paste here)
The failed.log use the pattern:

{ pattern: 'src/main/js/**/*.{js,html,css}', included: false}

The pass.log use the patterns:

{ pattern: 'src/main/js/**/*.js', included: false},
{ pattern: 'src/main/js/**/*.html', included: false},
{ pattern: 'src/main/js/**/*.css', included: false},

@fbengrid
Copy link

hiya,
here are the logs.Regards.

 Le Vendredi 17 juillet 2015 16h08, Friedel Ziegelmayer <notifications@github.com> a écrit :

Okay, the adapter seems to have nothing to do with it. Could you do me a big favor and add in your karma version manually the following line onto https://github.com/karma-runner/karma/blob/master/lib/file-list.js#L173log.debug('Fetching cache', pattern, path)
log.debug('Resolved', Object.keys(mg.statCache))and then run with log level set to DEBUG and paste me the output, thanks—
Reply to this email directly or view it on GitHub.

@dignifiedquire
Copy link
Member

I think tou sent the email to github instead of to me. my email is dignifiedquire@gmail.com and you can just paste it into gist.github.com if you want

@fbengrid
Copy link

oups..
ok sending it to you in gmail in a sec

@fbengrid
Copy link

I've just changed the pattern from

{ pattern: 'src/main/js/**/*.{js,html,css}', included: false}

to

{ pattern: 'src/main/js/**/*.+(js|html|css)', included: false},

and it's working now.

@dignifiedquire
Copy link
Member

Good to hear. I found the underlying issue which is related to inconsistencies in node-glob, so it will take a bit till it's fully fixed. Thanks for the detailed report.

@fbengrid
Copy link

glad to have helped.
Have fun and keep up the good work, this karma environment is a godsend !

@ghost
Copy link
Author

ghost commented Jul 17, 2015

@dignifiedquire fixed my issue as well.

@tomyam1
Copy link

tomyam1 commented Aug 6, 2015

Thanks @fbengrid . You've saved me tons of time!

@fbengrid
Copy link

fbengrid commented Aug 6, 2015

you're welcome :)

@indiesquidge
Copy link

+1 to @fbengrid's answer. Thanks a lot :)

@fbengrid
Copy link

fbengrid commented Jan 6, 2016

you're welcome :)

@Que3216
Copy link

Que3216 commented Jan 12, 2016

I got this issue when running Karma via Gulp via Gradle, using node 5.0.0. Changing the glob syntax didn't work. Instead upgrading node to 5.4.0 solved the problem.

abogaart added a commit to onehippo/frontend-build that referenced this issue Mar 14, 2016
…re files

When serving the fixture files via systemjs.includeFiles, Karma will try to load all fixtures files when Karma starts. This has weird results, for example, .html fixture files are added using a <link> tag, and CSS fixture files will always be present in the DOM for all tests, which is not necessary. So I changed the cfg.src.fixtures property into a detailed pattern object so Karma knows it can serve these files over http, but will not include them in the DOM by default.

 Next to that, I added support for loading .js fixture files and changed the 'extension' pattern for fixture files to work around this issue: karma-runner/karma#1494 (comment)
@msgesq
Copy link

msgesq commented May 31, 2016

I have the same issue using Karma (0.13.3) via Grunt with node (6.0.0). Will open a new issue as this one is closed ( New Issue #2158 ).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment