Validate error path for addDependency() (#197)#199
Conversation
| callback(null, js.code, js.map); | ||
| }, err => { | ||
| this.addDependency(err.file); | ||
| const file = err.filename || err.file; |
There was a problem hiding this comment.
this statement favors the err.filename value, is that intended?
There was a problem hiding this comment.
It wasn't accidental, but it is arbitrary. I don't have a reason to favor either over the other.
There was a problem hiding this comment.
Revisiting this, it occurs to me that one obvious reason to prefer err.file is that it maintains the status quo if there's an error value out there which has both properties. I'll push a change to switch the preference.
There was a problem hiding this comment.
https://github.com/sveltejs/svelte/blob/dafbdc286eef3de2243088a9a826e6899e20465c/src/compiler/utils/error.ts#L9
The property of CompileError is filename, not file. Checking is good, but I don't think file should be cared.
There was a problem hiding this comment.
It's been a while now, but I think I believed other error types were reachable here.
19dd98b to
79111a9
Compare
|
Why isn't this PR merged in? The crash is very annoying. I appreciate this merging-in pretty soon. |
|
Your potential appreciation of any 'pretty-soon' merging is duly noted. Thank you for informing us. |
|
@pngwn I'm sorry if my comment made you feeling bad but I really do not get the reason why this PR is halting. Are there any issue or something unclear? FYI: the crash won't happens when I don't use Lines 87 to 89 in 79111a9 |
No other reason that we are very busy. We'll get around to it as soon as we can. |
Fixes #197, which is caused by undefined being passed to the loader
addDependencymethod when handling errors. A Svelte CompileError doesn't have afileproperty, but it does havefilename, so try either of those and calladdDependencywith the value if it is a string (and not equal to the path of the top-level resource being loaded).In addition to updating tests, I've checked manually that error reporting and rebuilding after an error works in a webpack project that had been hitting
ERR_INVALID_ARG_TYPEbefore this patch.