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

CommandResponse.console.log buffering to mStdout may cause the node process to fail if it exceeds the heap size limit #1943

Open
zFernand0 opened this issue Sep 23, 2020 · 1 comment
Labels
bug Something isn't working priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex.

Comments

@zFernand0
Copy link
Member

The CommandResponse.console.log function...
https://github.com/zowe/imperative/blob/741f24f7246028879317dbd9590b91d7efbdef39/packages/cmd/src/response/CommandResponse.ts#L537-L547

Calls writeAndBufferStdout
https://github.com/zowe/imperative/blob/741f24f7246028879317dbd9590b91d7efbdef39/packages/cmd/src/response/CommandResponse.ts#L914-L919

Instead of buffering the data, we could Stream it! For example:

    private writeAndBufferStdout(data: Buffer | string) {
        Readable.from(data).on("data", (chunk) => {
          process.stdout.write(chunk);
        });
    }

The problem with this solution is that streaming is an async operation. In order to guarantee that the data is not piped or printed out of order, the streaming operation has to be promisify-ed.

This means that in order for you to produce output to the terminal, you need to await response.console.log(data), which forces the function that calls this to also be async (and also needs to be await-ed).

@robertblum-psi
Copy link

BTW: Same issue affects stderr, and yes huge amounts of data can be sent to stderr.

@zFernand0 zFernand0 added for-review To be reviewed in an Eng & Prod Mgmt meeting priority-medium Not functioning - next quarter if capacity permits labels Nov 29, 2022
@zFernand0 zFernand0 added bug Something isn't working severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex. and removed for-review To be reviewed in an Eng & Prod Mgmt meeting labels Dec 16, 2022
@awharn awharn transferred this issue from zowe/imperative Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex.
Projects
Status: Medium Priority
Development

No branches or pull requests

2 participants