I think this bug may be a feature from inheriting EventEmitter but i haven't got to dig that far just yet.
A working scenario that runs until terminated:
const NetcatClient = require('netcat/client');
const { spawn } = require('child_process');
// Bad example; made zombies - SORRY!!
//var child = spawn('bash', ['-c','cat /dev/urandom | base64 | nc -l -U /tmp/test.sock']);
var nc = new NetcatClient();
/**
* This works! Runs until interrupted as expected
*/
nc.enc('utf8').unixSocket('/tmp/test.sock').connect().pipe(process.stdout);
Chunked data terminates early without error/reason:
const NetcatClient = require('netcat/client');
const { spawn } = require('child_process');
// Bad example; made zombies - SORRY!!
//var child = spawn('bash', ['-c','cat /dev/urandom | /usr/bin/base64 | /bin/nc -l -U /tmp/test.sock']);
var nc = new NetcatClient();
/**
* This terminates early?!? (and silently?)
*/
nc.enc('utf8').unixSocket('/tmp/test.sock').connect()
.on('data', (chunk) => {
process.stdout.write(chunk);
});
Going to take a break and come back to this one. Will follow up if i find the issue or the correct implementation to achieve an endless stream of chunked data. The child process above will hang but you can always start up an external listener/feed as well to remove that side effect of the test case.
I think this bug may be a feature from inheriting
EventEmitterbut i haven't got to dig that far just yet.A working scenario that runs until terminated:
Chunked data terminates early without error/reason:
Going to take a break and come back to this one. Will follow up if i find the issue or the correct implementation to achieve an endless stream of chunked data. The child process above will hang but you can always start up an external listener/feed as well to remove that side effect of the test case.