jbt / docker

Documentation generator
http://jbt.github.com/docker
MIT License
234 stars 56 forks source link

Cryptic Error Message #24

Closed caseywebdev closed 11 years ago

caseywebdev commented 11 years ago

Ran into this error message today

<project path>/node_modules/docker/src/docker.js:265
          for(var i = 0; i < list.length; i += 1){
                                 ^
TypeError: Cannot read property 'length' of undefined
    at <project path>/node_modules/docker/src/docker.js:265:34
    at Object.oncomplete (fs.js:297:15)

After a little digging it seems that the error being thrown in fs.readdir is ignored, and list is left undefined. I added a console.error(err) and turns out I was running into the EMFILE error because my ulimit was too low (the default for OS X is only 256, yikes). I bumped it up and everything is working. I've run into this before with other Node.js programs and I've found a few reasonable solutions:

  1. Throw the error so people can Google it and realize what the problem is and how to fix it.
  2. Use a queue to only open one file at a time (could be pretty slow).
  3. Use a queue and a reasonable concurrency limit like async has.

Anyway, love the tool, great work!

jbt commented 11 years ago

Yeah very good point, I was running into this same thing a week or so ago when my kernel started throwing unnecessary EMFILEs - I'll add the thing to throw the error and also investigate intelligently working around it if that can be done without bloating the code too much.