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

fix(autowatch): add guard for missing file error #69

Closed
wants to merge 1 commit into from
Closed

fix(autowatch): add guard for missing file error #69

wants to merge 1 commit into from

Conversation

mewdriller
Copy link

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. Unfortunately, there
is not a custom type on the error, so we have to resort to string magic to
determine if that's the reason for the error.

Closes #40

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. Unfortunately, there
is not a custom type on the error, so we have to resort to string magic to
determine if that's the reason for the error.

Closes #40
@koggdal
Copy link

koggdal commented Aug 6, 2015

I can verify that this works for me at least. Thanks for fixing it! /ping @sokra

@@ -156,8 +156,18 @@ Plugin.prototype.readFile = function(file, callback) {
middleware.fileSystem.readFile("/_karma_webpack_/" + file.replace(/\\/g, "/"), callback);
}
}
if(!this.waiting)
doRead();
if (!this.waiting) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this fix is needed. Shouldn't be this.waiting truthy until all files are available?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have assumed so, but from testing on my local machine (Windows 7 x64), this.waiting was evaluating to false whenever a new file was added that matched the glob during a watch.

I really don't understand the internals that are going on here. I simply used the logic that I would have expected to run (in the this.waiting == true branch) in the case that we observed the specific error that was getting thrown. It's entirely possible there's a simpler / more elegant way to resolve this issue. If you've got any suggestions or improvements let me know and I'd be happy to update things.

@acr92
Copy link

acr92 commented Aug 21, 2015

+1 this fixed the problem for me.

@mewdriller
Copy link
Author

@sokra: Are there any changes you'd like me to make to the PR or is it good as-is?

/cc @dignifiedquire

@dignifiedquire
Copy link
Collaborator

looks good to me 👍

@cesarandreu
Copy link

+1 karma + webpack crash when I add a new file :(.

@dignifiedquire
Copy link
Collaborator

ping @sokra

@mewdriller
Copy link
Author

@sokra: Were you looking for this to be fixed in a different manner? If you've got another path you want me to pursue I can look into that.

@bassettsj
Copy link

👍 Seems like a great fix for the time being. Should be merged in. 😄

@le0pard
Copy link

le0pard commented Nov 6, 2015

+1

1 similar comment
@ddevault
Copy link

👍

@dignifiedquire
Copy link
Collaborator

ping @sokra

@MikaAK
Copy link
Contributor

MikaAK commented Sep 11, 2016

Is this still a thing I need to merge @dignifiedquire?

@dignifiedquire
Copy link
Collaborator

I don't think it's needed anymore. I haven't seen this error in a while anymore, so I would suggest closing it for now and if someone reproduces the issues with the latest versions looking into it again.

@MikaAK MikaAK closed this Sep 12, 2016
@Silviu-Marian
Copy link
Contributor

This is still needed...

image

@jsf-clabot
Copy link

jsf-clabot commented Jan 14, 2017

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@joshwiens
Copy link
Contributor

joshwiens commented Jan 14, 2017

@mewdriller Evidently this is still an issue, can you please reopen a PR to the v2 branch so this issue can be properly addressed.

If I don't hear anything by tomorrow evening, I will address this issue myself.

@joshwiens joshwiens self-assigned this Jan 14, 2017
@Silviu-Marian
Copy link
Contributor

Let me know if you need a repository that reproduces the issue.

@joshwiens
Copy link
Contributor

@Silviu-Marian - Given this was an issue under some contention in the past from what I can see above, that would be extremely helpful in getting this resolved quickly.

@Silviu-Marian
Copy link
Contributor

https://github.com/Silviu-Marian/karma-webpack-pr69

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

Successfully merging this pull request may close these issues.

None yet