Skip to content

QUA-218: Use streams to stringify large jsons #531

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

Merged
merged 2 commits into from
Jun 8, 2021

Conversation

noelia-lencina
Copy link
Contributor

https://codeclimate.atlassian.net/browse/QUA-218

This intends to process issues as a stream, to avoid passing a large json to JSON.stringify, which may cause memory problems.

var issueJson = buildIssueJson(message, path)
STDOUT(issueJson + "\u0000\n")
var readableJsonStream = buildIssueJson(message, path)
var output = ""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't instead be like follows ?

            var output = "" 
            readableJsonStream.on('data', (chunk) => {
              output = output + chunk
            })
            readableJsonStream.on('end', () => process.stdout.write(`${JSON.stringify(output)}` + "\u0000\n"))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to avoid applying stringify on large jsons, that's why it's applied on the chunks, building the string little by little. Does it make sense?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, it does.

@efueger
Copy link
Member

efueger commented May 17, 2021

@noelia-lencina - ready to merge?

@efueger
Copy link
Member

efueger commented May 25, 2021

@noelia-lencina to fix tests

@f-moya
Copy link

f-moya commented Jun 8, 2021

UPDATE

I followed Noe's advice and I converted the failing integration tests into system tests. The integration tests were failing because they used to depend too much on implementation details.

@f-moya f-moya merged commit c57239d into channel/eslint-7 Jun 8, 2021
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 this pull request may close these issues.

3 participants