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

execCommand throws on large outputs #474

Open
urugator opened this issue Jan 5, 2024 · 3 comments
Open

execCommand throws on large outputs #474

urugator opened this issue Jan 5, 2024 · 3 comments

Comments

@urugator
Copy link

urugator commented Jan 5, 2024

execCommand provides streaming ability via onStdout/onStderr option.
However, even if the option is provided, it still collects the output to own array:

output.stdout.push(chunk.toString(options.encoding))

When the output is very large it fails to convert the array to string:
https://github.com/steelbrain/node-ssh/blob/main/src/index.ts#L423-L424

RangeError: Invalid string length
    at Array.join (<anonymous>)
    at Channel.<anonymous> (redacted/node_modules/node-ssh/lib/esm/index.mjs:302:47)
    at Channel.emit (node:events:526:35)
    at Channel.doClose (redacted\node_modules\ssh2\lib\utils.js:101:21)
    at Object.onceWrapper (node:events:628:28)
    at Channel.emit (node:events:526:35)
    at endReadableNT (node:internal/streams/readable:1408:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Besides the error, I think it wastes resources and defeats the purpose of using streams.

@urugator urugator changed the title execCommand fails on large outputs execCommand throws on large outputs Jan 5, 2024
@steelbrain
Copy link
Owner

Besides the error, I think it wastes resources and defeats the purpose of using streams.

I agree. I am happy to accept a PR for this

@younes101020
Copy link

younes101020 commented Jan 8, 2025

hello @steelbrain any news about this ? i cant stream large logs :/

@steelbrain
Copy link
Owner

@younes101020 Thanks for writing in! Still happy to accept a contribution that fixes this

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

3 participants