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

gatsby-source-filesystem fails with "EMFILE: too many open files" #104

Closed
sroertgen opened this issue Nov 2, 2020 · 8 comments · Fixed by #107
Closed

gatsby-source-filesystem fails with "EMFILE: too many open files" #104

sroertgen opened this issue Nov 2, 2020 · 8 comments · Fixed by #107
Assignees

Comments

@sroertgen
Copy link
Contributor

When working with larger files (e.g. https://raw.githubusercontent.com/sroertgen/oeh-framework-bb/master/data/curriculum_bb_competences_skos.ttl) skohub-vocabs failed with the error: EMFILE: too many open files.

This gatsby issue seems to be related: gatsbyjs/gatsby#12011

I did a quick test installing graceful-fs and implementing the following like mentioned above in gatsby-node.js and webHookServer.js:

const gracefulFs = require('graceful-fs');
gracefulFs.gracefulify(fs);

Before making a pull request I would like to ask if you get the same error or it might be something special to my machine.

@acka47
Copy link
Member

acka47 commented Nov 2, 2020

I assume this has something to do with skohub-io/skohub-webhook#6? When I move the vocabs into the root folder it works. See https://skohub.io/acka47/oeh-framework-bb/heads/master/opencurricula/berlin-brandenburg/competences/index.html respectively https://github.com/acka47/oeh-framework-bb

@acka47
Copy link
Member

acka47 commented Nov 3, 2020

Did you maybe resolve skohub-io/skohub-webhook#6 with graceful-fs? Sounds like it to me. Then I propose you open a PR for this.

@sroertgen
Copy link
Contributor Author

ah, sorry, I should have searched the issues before opening this... I will prepare a PR

@sroertgen sroertgen self-assigned this Nov 3, 2020
@sroertgen
Copy link
Contributor Author

sroertgen commented Nov 19, 2020

unfortunately I just noticed that it fixes the build of https://raw.githubusercontent.com/sroertgen/oeh-framework-bb/master/data/curriculum_bb_competences_skos.ttl (about 10k vocabs), but it breaks with a even bigger file with 45.960 vocabs (e.g. https://raw.githubusercontent.com/openeduhub/oeh-metadata-eaf-schlagwortverzeichnis/main/data/eaf-graph-by-subject-all.ttl

success building schema - 1.715s
Built index {
  id: 0,
  items: 45960,
  cache: false,
  matcher: 0,
  worker: undefined,
  threshold: 0,
  depth: 0,
  resolution: 9,
  contextual: 0
}
success createPages - 107.064s

 ERROR 

glob error [Error: EMFILE: too many open files, scandir '.../skohub-vocabs/node_modules/gatsby/dist/internal-plugins/prod-404/src/pages'] {
  errno: -24,
  code: 'EMFILE',
  syscall: 'scandir',
  path: '.../skohub-vocabs/node_modules/gatsby/dist/internal-plugins/prod-404/src/pages'
}


 ERROR 

UNHANDLED REJECTION EMFILE: too many open files, scandir '.../skohub-vocabs/node_modules/gatsby/dist/internal-plugins/prod-404/src/pages'



  Error: EMFILE: too many open files, scandir '.../skohub-vocabs  /node_modules/gatsby/dist/internal-plugins/prod-404/src/pages'

not finished createPagesStatefully - 72.808s

Though it just breaks running npm run build. It works when running develop mode with npm start.

@literarymachine
Copy link
Contributor

Though it just breaks running npm run build. It works when running develop mode with npm start.

Does not work for me in both cases with eaf-graph-by-subject-all.ttl, works with curriculum_bb_competences_skos.ttl. I am guessing this is related to the amount of files being generated, not read, so I am not sure that this is a problem with gatsby-source-filesystem.

Anyways, using graceful-fs it works, although it takes a while:

Done building in 1594.909334812 sec

@dr0i
Copy link
Member

dr0i commented Nov 20, 2020

Could also be at OS level. On linux check allowed open files with ulimit -n and increase it doing e.g. ulimit -n 10240 (or more, my machine allows >1M, depends on machine (RAM). npm run build works fine on that machine using eaf-graph-by-subject-all.ttl in 680 sec.)
See https://stackoverflow.com/questions/8965606/node-and-error-emfile-too-many-open-files.

@sroertgen
Copy link
Contributor Author

That did the trick for me, thank you!
Done building in 2842.377295418 sec

@dr0i
Copy link
Member

dr0i commented Nov 20, 2020

We should consider to note this in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants