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

Error: EMFILE: too many open files #188

Closed
DivagarSivasamy opened this issue May 11, 2020 · 2 comments
Closed

Error: EMFILE: too many open files #188

DivagarSivasamy opened this issue May 11, 2020 · 2 comments

Comments

@DivagarSivasamy
Copy link

When i am writing a socket program for creating files and writing a file async .Even am using graceful-fs its not working for me .

function writingRefMaster(result) {
  const arrayOfRefMaster = result.map((jsonFileContent) => {
    const str = JSON.stringify(jsonFileContent.recordPguid);
    let _fileName = "test" + str.replace(/[&\/\\#,+()$~%.'":*?<>{}/\D/g]/g, "");
    // To generate exact ouput
    let output_fact = _preProcess.getrefMasterfinalOutput(
      jsonFileContent,
      _outputMapperJson
    );
    return fs.promises.writeFile(
      prop.get("OUTPUT_FILE_PATH") + `${_fileName}.json`,
      JSON.stringify(output_fact, null, 2)
    );
  });
  // I need to wait for async operation to understand when it is finished
  Promise.all(arrayOfRefMaster)
    .then(() => {
      console.log("files created");
    })
    .catch((err) => {
      console.log("error creating the files", err);
    });
}
@RyanZim
Copy link

RyanZim commented May 11, 2020

graceful-fs does not yet support fs.promises: #160

@DivagarSivasamy
Copy link
Author

ok fine got it.Thanks for your reply.

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

No branches or pull requests

2 participants