Fix: middleware can't deal with more than one source file correctly #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When rendering the first input file
options.outFile
is set once and later re-usedfor every subsequent file.
This caused two problems:
fileA.sass
andfileB.sass
in that order,the result of
fileB.sass
would overwritefileA.css
afaik.I never really got that far since:
node-sass
saves the callback in the suppliedoptions
object, overwriting the previous callback.When two
.css
were requested in parallel, this caused the callback of the first renderingprocess to be called twice and the callback of the second rendering process to be overwritten and
hence never called. Which THEN caused
done
(our callback) to be called twice, leading toError: Can't set headers after they are sent.
Here's the specific problematic line:
node-sass-middleware/middleware.js
Line 233 in 22fa1d4
As you can see we set
outFile
once and then re-use it for every subsequent rendering process.We also pass our initial
options
object tonode-sass
, which will save some own data in it causing problematic behavior when rendering more than one file at once.This PR fixes that.