diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-01-20 08:09:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-20 08:09:20 -0500 |
commit | 0b79fe377d9a851e06c48449f43db81acdd56caa (patch) | |
tree | 5315dee580d43bb69ead0825ba96a1cd66481829 /components | |
parent | 74d1f02a6a5668d64ea9f831e514b281d1a16864 (diff) | |
parent | 33988cd8aa49acea30611aef35c29faae9ae5160 (diff) | |
download | servo-0b79fe377d9a851e06c48449f43db81acdd56caa.tar.gz servo-0b79fe377d9a851e06c48449f43db81acdd56caa.zip |
Auto merge of #25552 - CYBAI:fix-25436, r=jdm
Return the highest priority error from the descendant instead of return the very first one
The test failed because we didn't return the highest priority error (which is network error in this case).
As Manish mentioned in https://github.com/servo/servo/issues/25436#issuecomment-571065323, that's because we're using the Promise.all trick to signal loads.
If we can avoid relying on Promise.all, maybe we don't need to do a complex logic like this; instead, ideally, we should always finish the module load immediately when we hit network failure so that we don't even need to do the `max()` comparison.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25436
- [x] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components')
-rw-r--r-- | components/script/script_module.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/components/script/script_module.rs b/components/script/script_module.rs index 91fca91e6a0..686583d9219 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -633,6 +633,7 @@ impl ModuleTree { } // 5-6. + let mut errors: Vec<ModuleError> = Vec::new(); let descendant_urls = module_tree.get_descendant_urls().borrow(); for descendant_module in descendant_urls @@ -650,13 +651,13 @@ impl ModuleTree { ModuleTree::find_first_parse_error(&global, &descendant_module, discovered_urls); // 8-4. - if child_parse_error.is_some() { - return child_parse_error; + if let Some(child_error) = child_parse_error { + errors.push(child_error); } } // Step 9. - return None; + return errors.into_iter().max(); } } |