node-disk-info
node-disk-info copied to clipboard
Error · EPIPE: broken pipe, write
I am running this module periodically on NODE 14.4 and on Windows.
Sometimes I get an unhandled error from the code:
return execSync(command,{windowsHide: true, encoding: 'buffer'});
If possible this error should be handled and not crash the whole node server.
Interesting, do you have the full error log available ?
Error EPIPE: broken pipe, write
internal/net.js:54:25 Socket._write
_stream_writable.js:352:12 writeOrBuffer
_stream_writable.js:303:10 Socket.Writable.write
child_process.js:645:20 Object.execSync
pkg/prelude/bootstrap.js:1507:30 Object.childProcess.execSync
C:\snapshot\node-localserver\node_modules\@deliverymanager\node-disk-info\dist\utils\utils.js:45:32 Function.execute
C:\snapshot\node-localserver\node_modules\@deliverymanager\node-disk-info\dist\platforms\windows.js:23:36 Function.run
C:\snapshot\node-localserver\node_modules\@deliverymanager\node-disk-info\dist\index.js:89:44 Object.getDiskInfoSync
C:\snapshot\node-localserver\info.js:98:26 saveLocalServerDataServer
C:\snapshot\node-localserver\info.js:169:20
C:\snapshot\node-localserver\node_modules\bluebird\js\release\util.js:16:23 tryCatcher
C:\snapshot\node-localserver\node_modules\bluebird\js\release\map.js:68:38 MappingPromiseArray._promiseFulfilled
C:\snapshot\node-localserver\node_modules\bluebird\js\release\promise_array.js:115:31 MappingPromiseArray.<anonymous>
C:\snapshot\node-localserver\node_modules\bluebird\js\release\promise_array.js:79:10 MappingPromiseArray.init
C:\snapshot\node-localserver\node_modules\bluebird\js\release\map.js:37:10 MappingPromiseArray._asyncInit
C:\snapshot\node-localserver\node_modules\bluebird\js\release\async.js:97:12 _drainQueueStep
I have been using my fork but it is pretty much the same.
I have tried adding the following, but I am not so sure it will work and I have no actual way of testing because it is a very random error that crashes the whole node app.
public static execute(command: string): Buffer {
try {
return execSync(command, { windowsHide: true, encoding: 'buffer' });
} catch (err) {
console.log('err', err);
return Buffer.from('\r\r\n', 'utf8');
}
}
You also forgot to place the windowsHide to your new chcp command
return execSync('chcp', { windowsHide: true }).toString().split(':')[1].trim();
I have more news on the
try {
return execSync(command, { windowsHide: true, encoding: 'buffer' });
} catch (err) {
console.log('err', err);
return Buffer.from('\r\r\n', 'utf8');
}
IT DOES NOT WORK. execSync still crashes the node app giving the Error · EPIPE: broken pipe, write
Hello, unfortunately I am not able to reproduce the error you have. but could you try those solution:
Solution 1:
try {
return execSync(command, {stdio: ['pipe', 'pipe', 'ignore'], windowsHide: true, encoding: 'buffer' });
} catch (err) {
console.log('err', err);
return Buffer.from('\r\r\n', 'utf8');
}
Solution 2:
try {
return execSync(command, { stdio: ['pipe', 'pipe', process.stderr], windowsHide: true, encoding: 'buffer' });
} catch (err) {
console.log('err', err);
return Buffer.from('\r\r\n', 'utf8');
}
Is far as I know, stdio is : stdin, stdout, and stderr By making stderr to ignore the pipe error may go away and you should have the error in the console. By making stderr to process.stderr the catch may work better ...
@deliverymanager any news about this problem ?