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

catch css file not found #2206

Merged
merged 4 commits into from Nov 5, 2018
Merged

Conversation

d3caf
Copy link
Contributor

@d3caf d3caf commented Oct 27, 2018

↪️ Pull Request

This should close #2168. The issue was that md5.js was trying to create a hash of a non-existent file and not catching the error. I believe I've fixed it by moving the error listener above the pipe and then adding a try/catch in RawAsset on generateHash(). I'm definitely open to suggestions on how to improve it. This is my first PR for Parcel and I haven't had a ton of experience with Node apps 😉

💻 Examples

🚨 Test instructions

  1. Create a CSS file that attempts to use a non-existent image (i.e. as a background-image)
  2. Build said CSS file

✔️ PR Todo

  • Added/updated unit tests for this change --> might need some pointers on this if necessary

  • Filled out test instructions (In case there aren't any unit tests)

  • Included links to related issues/PRs

@d3caf
Copy link
Contributor Author

d3caf commented Oct 27, 2018

Looks like tests exited with 1 on Windows but passed on all other platforms...?

@Taym95
Copy link
Contributor

Taym95 commented Oct 29, 2018

Only Windows node_10_x weird!

@d3caf
Copy link
Contributor Author

d3caf commented Oct 29, 2018

Looks like it's a corrupt binary? Looking at line 1685 of the console output.

2018-10-27T02:32:15.7060230Z [==================================================] - 1 / 1-- CORRUPT BINARY - D:\a\1\s\packages\core\parcel-bundler\test\integration\elm\elm-stuff\0.19.0\Main.elmo

@DeMoorJasper
Copy link
Member

Restarted the tests hopefully they pass now

@d3caf
Copy link
Contributor Author

d3caf commented Nov 5, 2018

@DeMoorJasper looks like almost every PR has failing tests 😕

try {
return await md5.file(this.name);
} catch (err) {
throw new Error(err);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to catch and re-throw the error here? Isn't that the same as just not catching it in the first place?

@@ -11,11 +11,13 @@ function md5(string, encoding = 'hex') {
md5.file = function(filename) {
return new Promise((resolve, reject) => {
fs.createReadStream(filename)
.on('error', function(error) {
reject(error);
Copy link
Member

Choose a reason for hiding this comment

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

I think you can write this like before by just passing reject directly as the callback instead of making a wrapper function

@d3caf
Copy link
Contributor Author

d3caf commented Nov 5, 2018

@devongovett good points on both of your comments. Think I got it cleaned up now. Thanks!

@devongovett devongovett merged commit 9136cdc into parcel-bundler:master Nov 5, 2018
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.

Die after file is not found in css
4 participants