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

Introduce a queue such that a Node thread is available for fs tasks #132

Merged
merged 1 commit into from
Aug 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var sass = require('node-sass');
var path = require('path');
var os = require('os');
var fs = require('fs');
var async = require('async');

// A typical sass error looks like this
var SassError = {
Expand All @@ -16,6 +17,12 @@ var SassError = {
};
var resolveError = /Cannot resolve/;

// This queue makes sure node-sass leaves one thread available for executing
// fs tasks when running the custom importer code.
// This can be removed as soon as node-sass implements a fix for this.
var threadPoolSize = process.env.UV_THREADPOOL_SIZE || 4;
var asyncSassJobQueue = async.queue(sass.render, threadPoolSize - 1);

/**
* The sass-loader makes node-sass available to webpack modules.
*
Expand Down Expand Up @@ -155,7 +162,8 @@ module.exports = function (content) {
throw err;
}
}
sass.render(opt, function onRender(err, result) {

asyncSassJobQueue.push(opt, function onRender(err, result) {
if (err) {
formatSassError(err);
callback(err);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"node-sass": "^3.1.0"
},
"dependencies": {
"async": "^1.4.0",
"loader-utils": "^0.2.5"
},
"devDependencies": {
Expand Down