-
Notifications
You must be signed in to change notification settings - Fork 71
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
Callback/EOI never returns #96
Comments
I think I see the problem - you create a random string called The problem is that this line is not always streamed on it's own but sometimes together with the user's commands so
But it expects this separately like this:
Whether the output is streamed together or not is up to So this line in if(chunk.compare(this.EOI) === 0) {
cb();
return this.emit('EOI');
} It's doing a direct, absolute compare where it should be looking for the |
OK, I think we have a fix: _write(chunk, encoding, cb) {
// HERE
if(chunk.indexOf(this.EOI) >= 0) {
this.chunksArray.push(chunk);
cb();
return this.emit('EOI');
}
this.chunksArray.push(chunk);
return cb();
}
isEmpty() {
return this.chunksArray.length === 0;
}
getContents() {
return Buffer.concat(this.chunksArray);
}
getContentsAsString(encoding = 'utf8') {
// AND HERE
return Buffer.concat(this.chunksArray).toString(encoding).replace(/\0/g, '').replace(this.EOI,'');
} |
@cawoodm I'm not sure if that is a fix, e.g. something trivial like printing |
It works for my application, feel free to improve on it. |
I have a similar problem to #94 where invoke() does not return. The problem is intermittant. In my application I have 4 instances of a Vue component which each instantiate their own
Shell
and callGet-Service
. As you can see below, 3 of the 4 processes return whilst the 4th (PID 15456) does not. Repeat and only 2 return. About one in 10 times all 4 return.Here's the code: https://github.com/cawoodm/powershell-servicemanager
Could it be that the EOI detection is shaky? How does it work exactly?
The text was updated successfully, but these errors were encountered: