node-sass: Render with custom import hangs

Given the following fs.readFile never executes it’s callback and process hang indefinitely.

// entry.scss
@import "_partial";
// _partial.scss
foo{}
var fs = require('fs');
var sass = require('node-sass');

var files = [
    'entry.scss',
    'entry.scss',
    'entry.scss',
    'entry.scss',
];

files.forEach(function (file) {
    sass.render({
        file: file,
        importer: function (uri, prev, done) {
            var filename = process.cwd() + '/' + uri;
            console.log('fs.readFile:', filename);
            fs.readFile(filename, function(err, data) {
                console.log('I am never executed');
                done({ contents: data });
            });
        }
    }, function(err, result) {
        console.log('successfully rendered');
    });
});

Outputs this and hangs

➜  node-sass-test  node index.js
fs.readFile: /Users/michael/node-sass-test/_partial.scss
fs.readFile: /Users/michael/node-sass-test/_partial.scss
fs.readFile: /Users/michael/node-sass-test/_partial.scss
fs.readFile: /Users/michael/node-sass-test/_partial.scss

This example works fine if:

  • I only have 3 files
  • I use renderSync
  • I use fs.readFileSync

This is potentially related to https://github.com/sass/node-sass/issues/794.


This issue has been reproduced on multiple OSX machines on the latest node 0.10, 0.12 and iojs with node-sass@3.0.0-beta.5

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Comments: 38 (26 by maintainers)

Commits related to this issue

Most upvoted comments

I think I have it identified. Workaround: env UV_THREADPOOL_SIZE=5 node indes.js πŸ˜ƒ