Add a missing _ignoreErrors() call in StylesheetGraph (#377)

We weren't ignoring errors when reloading a file, which meant that
syntax errors would get surfaced in the wrong place and cause a crash.

Closes #359
This commit is contained in:
Natalie Weizenbaum 2018-06-26 20:10:46 -07:00 committed by GitHub
parent e95d57ce25
commit 39eeeb51ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -8,7 +8,11 @@
* Fix a bug where `@-moz-document` functions with string arguments weren't being
parsed.
### Command-Line Interface
* Don't crash when a syntax error is added to a watched file.
## 1.7.1
* Fix crashes in released binaries.

View File

@ -122,7 +122,8 @@ class StylesheetGraph {
_transitiveModificationTimes.clear();
importCache.clearImport(canonicalUrl);
var stylesheet = importCache.importCanonical(node.importer, canonicalUrl);
var stylesheet = _ignoreErrors(
() => importCache.importCanonical(node.importer, canonicalUrl));
if (stylesheet == null) {
remove(canonicalUrl);
return null;

View File

@ -118,6 +118,21 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
.validate();
});
test("when it gets a parse error", () async {
await d.file("test.scss", "a {b: c}").create();
var sass = await watch(["test.scss:out.css"]);
await expectLater(sass.stdout, emits('Compiled test.scss to out.css.'));
await expectLater(sass.stdout, _watchingForChanges);
await d.file("test.scss", "a {b: }").create();
await expectLater(sass.stderr, emits('Error: Expected expression.'));
await expectLater(sass.stderr, emitsThrough(contains('test.scss 1:7')));
await sass.kill();
await d.nothing("out.css").validate();
});
group("when its dependency is deleted", () {
test("and removes the output", () async {
await d.file("_other.scss", "a {b: c}").create();