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

Node 0.11 error on etag #63

Closed
elado opened this issue Sep 16, 2014 · 4 comments
Closed

Node 0.11 error on etag #63

elado opened this issue Sep 16, 2014 · 4 comments

Comments

@elado
Copy link

elado commented Sep 16, 2014

Node 0.11 and send throws an error:

app/node_modules/browser-sync/node_modules/serve-static/node_modules/send/node_modules/etag/index.js:55
    throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
          ^
TypeError: argument entity must be string, Buffer, or fs.Stats
    at etag (app/node_modules/browser-sync/node_modules/serve-static/node_modules/send/node_modules/etag/index.js:55:11)
    at SendStream.setHeader (app/node_modules/browser-sync/node_modules/serve-static/node_modules/send/index.js:725:15)
    at SendStream.send (app/node_modules/browser-sync/node_modules/serve-static/node_modules/send/index.js:500:8)
    at app/node_modules/browser-sync/node_modules/serve-static/node_modules/send/index.js:631:12
    at Object.oncomplete (fs.js:97:15)

The reason seems to be that fs.stat doesn't return instanceof fs.Stats as etag expects.

I added a log to SendStream#sendIndex:

SendStream.prototype.sendIndex = function sendIndex(path){
  var i = -1;
  var self = this;

  function next(err){
    if (++i >= self._index.length) {
      if (err) return self.onStatError(err);
      return self.error(404);
    }

    var p = join(path, self._index[i]);

    debug('stat "%s"', p);
    fs.stat(p, function(err, stat){
      // LOG
      console.log("STAT?", stat instanceof fs.Stats);
      // END LOG
      if (err) return next(err);
      if (stat.isDirectory()) return next();
      self.emit('file', p, stat);
      self.send(p, stat);
    });
  }

  next();
};

It outputs false.

etag is expecting a Stats instance:

https://github.com/jshttp/etag/blob/master/index.js#L44

Works on 0.10.

@dougwilson
Copy link
Contributor

This is not a bug here, it is a bug with graceful-fs 3.0 and node.js 0.11.13. Either use node.js 0.11.12 or downgrade all the graceful-fs modules in your tree to less than 3.0 until a fix is released.

@dougwilson
Copy link
Contributor

Link to graceful-fs bug: isaacs/node-graceful-fs#31

@elado
Copy link
Author

elado commented Sep 16, 2014

Thanks for clarifying.

@dougwilson
Copy link
Contributor

graceful-fs 3.0.3 has been released with the fix. In addition, the dependency has been working-around the issue for a while now :)

@pillarjs pillarjs locked and limited conversation to collaborators Oct 7, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants