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

how to use createReadStream instead of readFileSync #171

Open
at4446 opened this issue May 13, 2021 · 0 comments
Open

how to use createReadStream instead of readFileSync #171

at4446 opened this issue May 13, 2021 · 0 comments

Comments

@at4446
Copy link

at4446 commented May 13, 2021

I was wondering how it is possible to use createReadStream instead of readFileSync? I am trying to read an xml which is 500MB so node is running out of heap memory so I need to read the file in chunk instead.
let json = convert.xml2js( fs.readFileSync(entities.xml), { instructionHasAttributes: true, compact: true, spaces: 4, reversible: true, } );

when I change fs readFileSync to fs.createReadStream I get the following error:

UnhandledPromiseRejectionWarning: Error: Text data outside of root node.

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

1 participant