{"action":"created","issue":{"url":"https://api.github.com/repos/shama/gaze/issues/73","labels_url":"https://api.github.com/repos/shama/gaze/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/shama/gaze/issues/73/comments","events_url":"https://api.github.com/repos/shama/gaze/issues/73/events","html_url":"https://github.com/shama/gaze/issues/73","id":26927465,"number":73,"title":"Consider using graceful-fs to fix EMFILE error","user":{"login":"rstacruz","id":74385,"avatar_url":"https://avatars.githubusercontent.com/u/74385?v=3","gravatar_id":"","url":"https://api.github.com/users/rstacruz","html_url":"https://github.com/rstacruz","followers_url":"https://api.github.com/users/rstacruz/followers","following_url":"https://api.github.com/users/rstacruz/following{/other_user}","gists_url":"https://api.github.com/users/rstacruz/gists{/gist_id}","starred_url":"https://api.github.com/users/rstacruz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstacruz/subscriptions","organizations_url":"https://api.github.com/users/rstacruz/orgs","repos_url":"https://api.github.com/users/rstacruz/repos","events_url":"https://api.github.com/users/rstacruz/events{/privacy}","received_events_url":"https://api.github.com/users/rstacruz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-02-05T00:03:32Z","updated_at":"2015-01-01T09:58:58Z","closed_at":"2014-02-05T00:22:16Z","body":"I'm sure everyone's encountered the dreaded `EMFILE: Too many opened files` error at some point.\r\n\r\nThe package graceful-fs (https://npmjs.org/package/graceful-fs) is a drop-in replacement for `fs`, where `fs.watch` is reimplemented to queue up retries when errors happen.\r\n\r\nHere's an example of a gaze-related error (via gulpjs.com):\r\n\r\n```\r\n ✈  gulp watch\r\n[gulp] Using file /myproject/gulpfile.js\r\n[gulp] Working directory changed to /myproject\r\n[gulp] Running 'watch'...\r\n[gulp] Finished 'watch' in 4.78 ms\r\n\r\nevents.js:72\r\n        throw er; // Unhandled 'error' event\r\n              ^\r\nError: EMFILE: Too many opened files.\r\n    at Gaze._handleError (/myproject/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:414:31)\r\n    at Gaze._watchDir (/myproject/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:292:17)\r\n    at /myproject/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:336:10\r\n    at iterate (/myproject/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)\r\n```"},"comment":{"url":"https://api.github.com/repos/shama/gaze/issues/comments/68483459","html_url":"https://github.com/shama/gaze/issues/73#issuecomment-68483459","issue_url":"https://api.github.com/repos/shama/gaze/issues/73","id":68483459,"user":{"login":"colinmegill","id":1770265,"avatar_url":"https://avatars.githubusercontent.com/u/1770265?v=3","gravatar_id":"","url":"https://api.github.com/users/colinmegill","html_url":"https://github.com/colinmegill","followers_url":"https://api.github.com/users/colinmegill/followers","following_url":"https://api.github.com/users/colinmegill/following{/other_user}","gists_url":"https://api.github.com/users/colinmegill/gists{/gist_id}","starred_url":"https://api.github.com/users/colinmegill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinmegill/subscriptions","organizations_url":"https://api.github.com/users/colinmegill/orgs","repos_url":"https://api.github.com/users/colinmegill/repos","events_url":"https://api.github.com/users/colinmegill/events{/privacy}","received_events_url":"https://api.github.com/users/colinmegill/received_events","type":"User","site_admin":false},"created_at":"2015-01-01T09:58:58Z","updated_at":"2015-01-01T09:58:58Z","body":"@shama Thanks! Back home and back at it... that did seem to do something.\r\nThe livereload process no longer crashes and having added it to my PATH,\r\nthis is durable. Seems hacky but I can accept it. In place of crashing, I\r\nnow have a geometrically expanding list of errors:\r\n\r\n```\r\n\r\n[gulp-sane-watch] 1 file changed (index.html)\r\n\r\n[gulp] Running 'js'...\r\n\r\n[gulp] Finished 'js' in 3.71 ms\r\n\r\n[gulp] Running 'html'...\r\n\r\n[gulp] Finished 'html' in 399 μs\r\n\r\n[gulp] Running 'watchAndReload'...\r\n\r\n[gulp] Finished 'watchAndReload' in 164 μs\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n2015-01-01 01:54 node[694] (CarbonCore.framework) FSEventStreamStart:\r\nregister_with_server: ERROR: f2d_register_rpc() => (null) (-21)\r\n\r\n```\r\n\r\nI looked around and saw some references to sane, so I tried\r\ngulp-sane-watch, but to no avail. Any suggestions? Here's my gulpfile:\r\n\r\n```\r\n\r\nvar gulp = require(\"gulp\");\r\n\r\nvar browserify = require(\"browserify\");\r\n\r\nvar concat = require(\"gulp-concat\");\r\n\r\nvar jsx = require(\"gulp-jsx\");\r\n\r\nvar source = require(\"vinyl-source-stream\");\r\n\r\nvar del = require(\"del\");\r\n\r\nvar reactify = require(\"reactify\");\r\n\r\nvar livereload = require(\"gulp-livereload\");\r\n\r\nvar embedlr = require(\"gulp-embedlr\");\r\n\r\nvar sass = require(\"gulp-sass\");\r\n\r\nvar path = require(\"path\")\r\n\r\nvar cssmin = require(\"gulp-cssmin\");\r\n\r\nvar autoprefixer = require(\"gulp-autoprefixer\");\r\n\r\nvar saneWatch = require('gulp-sane-watch');\r\n\r\n\r\n\r\ngulp.task(\"clean\", function(cb){\r\n\r\ndel([\"dist\"], cb)\r\n\r\n});\r\n\r\n\r\ngulp.task(\"css\", function () {\r\n\r\n  return gulp.src(\"./src/css/main.scss\")\r\n\r\n    .pipe(sass({errLogToConsole: true}))\r\n\r\n    .pipe(autoprefixer())\r\n\r\n    .pipe(cssmin())\r\n\r\n    .pipe(gulp.dest(\"./dist\"))\r\n\r\n    .pipe(livereload());\r\n\r\n});\r\n\r\n\r\ngulp.task(\"js\", function() {\r\n\r\n    // Single entry point to browserify\r\n\r\n    browserify({\r\n\r\n    entries: [\"./src/js/main.js\"],\r\n\r\n    extensions: [\".jsx\"],\r\n\r\n    paths: [\"./node_modules\", \"./src/js\"]\r\n\r\n    })\r\n\r\n    .transform(reactify)\r\n\r\n    .bundle()\r\n\r\n        .pipe(source(\"main.js\"))\r\n\r\n        // if desired, pipe to uglify or other tasks here before writing to\r\ndisk\r\n\r\n        .pipe(gulp.dest(\"./dist/\"))\r\n\r\n        .pipe(livereload());\r\n\r\n});\r\n\r\n\r\ngulp.task(\"html\", function() {\r\n\r\ngulp.src(\"./src/index.html\")\r\n\r\n        .pipe(embedlr())\r\n\r\n.pipe(gulp.dest(\"./dist/\"))\r\n\r\n        .pipe(livereload())\r\n\r\n})\r\n\r\n\r\ngulp.task(\"watchAndReload\", function() {\r\n\r\n    livereload.listen()\r\n\r\n    saneWatch(\"./src/**/*\", function() {\r\n\r\n        gulp.start(\"default\");\r\n\r\n    });\r\n\r\n});\r\n\r\n\r\n// gulp.task(\"watchSrc\", function() {\r\n\r\n//     gulp.watch([\"./src/**/*\"], [\"default\"]);\r\n\r\n// });\r\n\r\n\r\ngulp.task(\"default\", [\"js\", \"css\", \"html\", \"watchAndReload\"])\r\n\r\n```\r\n\r\nThanks again!\r\n\r\n\r\nᐧ\r\n\r\nOn Wed, Dec 31, 2014 at 8:07 PM, Kyle Robinson Young <\r\nnotifications@github.com> wrote:\r\n\r\n> @colinmegill <https://github.com/colinmegill> Happy new year to you!\r\n> Check out this link:\r\n> http://yabfog.com/blog/2014/10/22/yosemite-upgrade-changes-open-file-limit\r\n>\r\n> —\r\n> Reply to this email directly or view it on GitHub\r\n> <https://github.com/shama/gaze/issues/73#issuecomment-68480006>.\r\n>"}}