Skip to content
New issue

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

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

Already on GitHub? # to your account

fix(readFile): handle path doesn't exist error for new file #208

Merged
merged 1 commit into from
Jan 19, 2017

Conversation

joshwiens
Copy link
Contributor

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

With auto watch enabled, add a new test after the initial rest run and it will throw.

Reproducible here. Thanks @Silviu-Marian
https://github.com/Silviu-Marian/karma-webpack-pr69

What is the new behavior?

Added a try/catch clause to guard against a "Path doesn't exist" error
coming from MemoryFileSystem.prototype.readFileSync when a new file is
added to the file-system that matches the files glob.

Does this PR introduce a breaking change?

  • Yes
  • No

If this PR contains a breaking change, please describe the following...

  • Impact:
  • Migration path for existing applications:
  • Github Issue(s) this is regarding:

Other information:

Closes #40
Closes #69

@joshwiens joshwiens added this to the 2.0.2 milestone Jan 18, 2017
@joshwiens joshwiens force-pushed the d3viant0ne-AutowatchGuard branch from b57d28b to c182c2c Compare January 18, 2017 00:35
@joshwiens joshwiens force-pushed the d3viant0ne-AutowatchGuard branch from c182c2c to d319c68 Compare January 18, 2017 01:51
@joshwiens joshwiens merged commit 907ed72 into v2 Jan 19, 2017
@joshwiens joshwiens deleted the d3viant0ne-AutowatchGuard branch January 19, 2017 06:24
@radhikaa
Copy link

radhikaa commented Feb 3, 2017

@d3viant0ne I am facing the same issue as mentioned above in my project. I have a file glob mentioned in the karma config. I have spec files created in my project that match this file pattern. When I run the tests, I get the "Path doesn't exist" error coming from MemoryFileSystem.prototype.readFileSync.

There are multiple solutions suggested in various links including:

  1. change 'tests/**.spec.js' to '../tests/**spec.js' so that we come of the '_karma_webpack' path
  2. do not set 'entry' for webpack in its config
  3. use this method of creating a single entry point instead of file pattern and make changes to config accordingly

Unfortunately, none of these solutions are working for me.

I cannot capture the exact fix that you have posted for this issue. Could you suggest a way out of this problem?

@Silviu-Marian
Copy link
Contributor

K:\www\wrk\amazingthings-web-app>npm update karma-webpack
amazingthings@2.2.0 K:\www\wrk\amazingthings-web-app
`-- karma-webpack@2.0.2

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.17

K:\www\wrk\amazingthings-web-app>npm test

> amazingthings@2.2.0 test K:\www\wrk\amazingthings-web-app
> nodemon --exitcrash -w karma.conf.js karma.js

[nodemon] 1.11.0

[nodemon] starting `node karma.js`enter `rs`
Happy[1]: Version: 3.0.2. Using cache? yes. Threads: 3
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
webpack: wait until bundle finished:
Happy[1]: Loaded 34 entries from cache. (0 were stale)
Happy[1]: All set; signalling webpack to proceed.
Build co 03 02 2017 11:17:17.810:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#gUMs_pt6iAnktTCGAAAA with id 95424312
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 32 of 32 SUCCESS (1.728 secs / 1.447 secs)
webpack: Compiling...

  build [=            ] 10%03 02 2017 11:18:39.803:ERROR [karma]: { Error: no such file or directory
    at MemoryFileSystem.readFileSync (K:\www\wrk\amazingthings-web-app\node_modules\memory-fs\lib\MemoryFileSystem.js:107:10)
    at MemoryFileSystem.(anonymous function) [as readFile] (K:\www\wrk\amazingthings-web-app\node_modules\memory-fs\lib\MemoryFileSystem.js:300:34)
    at doRead (K:\www\wrk\amazingthings-web-app\node_modules\karma-webpack\lib\karma-webpack.js:203:29)
    at Plugin.readFile (K:\www\wrk\amazingthings-web-app\node_modules\karma-webpack\lib\karma-webpack.js:208:7)
    at K:\www\wrk\amazingthings-web-app\node_modules\karma-webpack\lib\karma-webpack.js:233:19
    at nextPreprocessor (K:\www\wrk\amazingthings-web-app\node_modules\karma\lib\preprocessor.js:36:26)
    at K:\www\wrk\amazingthings-web-app\node_modules\karma\lib\preprocessor.js:122:9
    at module.exports (K:\www\wrk\amazingthings-web-app\node_modules\karma\node_modules\isbinaryfile\index.js:28:12)
    at K:\www\wrk\amazingthings-web-app\node_modules\karma\lib\preprocessor.js:84:7
    at K:\www\wrk\amazingthings-web-app\node_modules\karma\node_modules\graceful-fs\graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
  code: 'ENOENT',
  errno: 34,
  message: 'no such file or directory',
  path: '/_karma_webpack_/v2/Components/Dropdown.spec.js' }
  build [=======      ] 50%[nodemon] app crashed

> amazingthings@2.2.0 posttest K:\www\wrk\amazingthings-web-app
> npm run test


Looks like the problem is still here.
Using karma-webpack@2.0.2

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants