{"action":"created","issue":{"url":"https://api.github.com/repos/atom/electron/issues/1903","labels_url":"https://api.github.com/repos/atom/electron/issues/1903/labels{/name}","comments_url":"https://api.github.com/repos/atom/electron/issues/1903/comments","events_url":"https://api.github.com/repos/atom/electron/issues/1903/events","html_url":"https://github.com/atom/electron/issues/1903","id":86234325,"number":1903,"title":"Electron and graceful-fs don't seem to work","user":{"login":"bpasero","id":900690,"avatar_url":"https://avatars.githubusercontent.com/u/900690?v=3","gravatar_id":"","url":"https://api.github.com/users/bpasero","html_url":"https://github.com/bpasero","followers_url":"https://api.github.com/users/bpasero/followers","following_url":"https://api.github.com/users/bpasero/following{/other_user}","gists_url":"https://api.github.com/users/bpasero/gists{/gist_id}","starred_url":"https://api.github.com/users/bpasero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpasero/subscriptions","organizations_url":"https://api.github.com/users/bpasero/orgs","repos_url":"https://api.github.com/users/bpasero/repos","events_url":"https://api.github.com/users/bpasero/events{/privacy}","received_events_url":"https://api.github.com/users/bpasero/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/atom/electron/labels/asar","name":"asar","color":"f7c6c7"},{"url":"https://api.github.com/repos/atom/electron/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-06-08T16:02:27Z","updated_at":"2015-06-10T06:21:21Z","closed_at":"2015-06-09T05:50:28Z","body":"I am using Electron 0.27.1 on a Mac and notice that graceful-fs cannot be used to prevent EMFILE errors. \r\n\r\nTo reproduce take belows application and change the folder in index.html to a folder with lots of javascript files. In my testing I needed at least 1000 files to cause issues. Run the application and I immediately get following output: Error EMFILE too many files open.\r\n\r\nIf I run the script bare with node.js or io.js I do not see the error so I assume Electrons way of patching the fs module for asar support is not compatible with graceful-fs way.\r\n\r\nAny help how to correctly use graceful-fs is appreciated. \r\n\r\nindex.html:\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <title>Hello World!</title>\r\n    <script>\r\n      var gracefulfs = require(\"graceful-fs\");\r\n      console.log(\"is graceful loaded: \" + !!gracefulfs);\r\n\r\n      var glob = require(\"glob\");\r\n      glob(\"/<path to lots of js files>/**/*.js\", function(error, matches) {\r\n        matches = matches.slice(0, 1000);\r\n        matches.forEach(function(m) {\r\n          gracefulfs.readFile(m, function(e, c) {\r\n            if (e) {\r\n              console.log(e);\r\n            }\r\n          });\r\n        });\r\n      });\r\n      \r\n      </script>\r\n  </head>\r\n  <body>\r\n   \r\n  </body>\r\n</html>\r\n```\r\n\r\npackage.json:\r\n```json\r\n{\r\n  \"name\"    : \"your-app\",\r\n  \"version\" : \"0.1.0\",\r\n  \"main\"    : \"main.js\",\r\n  \"dependencies\": {\r\n    \"glob\": \"*\",\r\n    \"graceful-fs\": \"*\"\r\n  }\r\n}\r\n```\r\n\r\nmain.js:\r\n```javascript\r\nvar app = require('app');  // Module to control application life.\r\nvar BrowserWindow = require('browser-window');  // Module to create native browser window.\r\n\r\n// Report crashes to our server.\r\nrequire('crash-reporter').start();\r\n\r\n// Keep a global reference of the window object, if you don't, the window will\r\n// be closed automatically when the javascript object is GCed.\r\nvar mainWindow = null;\r\n\r\n// Quit when all windows are closed.\r\napp.on('window-all-closed', function() {\r\n  if (process.platform != 'darwin')\r\n    app.quit();\r\n});\r\n\r\n// This method will be called when Electron has done everything\r\n// initialization and ready for creating browser windows.\r\napp.on('ready', function() {\r\n  // Create the browser window.\r\n  mainWindow = new BrowserWindow({width: 800, height: 600, show: true});\r\n\r\n  // and load the index.html of the app.\r\n  mainWindow.loadUrl('file://' + __dirname + '/index.html');\r\n\r\n  // Open the devtools.\r\n  mainWindow.openDevTools();\r\n\r\n  // Emitted when the window is closed.\r\n  mainWindow.on('closed', function() {\r\n    // Dereference the window object, usually you would store windows\r\n    // in an array if your app supports multi windows, this is the time\r\n    // when you should delete the corresponding element.\r\n    mainWindow = null;\r\n  });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/atom/electron/issues/comments/110609077","html_url":"https://github.com/atom/electron/issues/1903#issuecomment-110609077","issue_url":"https://api.github.com/repos/atom/electron/issues/1903","id":110609077,"user":{"login":"bpasero","id":900690,"avatar_url":"https://avatars.githubusercontent.com/u/900690?v=3","gravatar_id":"","url":"https://api.github.com/users/bpasero","html_url":"https://github.com/bpasero","followers_url":"https://api.github.com/users/bpasero/followers","following_url":"https://api.github.com/users/bpasero/following{/other_user}","gists_url":"https://api.github.com/users/bpasero/gists{/gist_id}","starred_url":"https://api.github.com/users/bpasero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpasero/subscriptions","organizations_url":"https://api.github.com/users/bpasero/orgs","repos_url":"https://api.github.com/users/bpasero/repos","events_url":"https://api.github.com/users/bpasero/events{/privacy}","received_events_url":"https://api.github.com/users/bpasero/received_events","type":"User","site_admin":false},"created_at":"2015-06-10T06:21:21Z","updated_at":"2015-06-10T06:21:21Z","body":"> I believe Chromium has restricted the number of maximum opened files\r\n\r\nOk thats interesting. Would it be possible to lift this restriction, similar to how Electron lifts the storage quota?"}}