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

Error · EPIPE: broken pipe, write #22

Open
deliverymanager opened this issue May 8, 2021 · 8 comments
Open

Error · EPIPE: broken pipe, write #22

deliverymanager opened this issue May 8, 2021 · 8 comments

Comments

@deliverymanager
Copy link

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.

@Ekristoffe
Copy link
Contributor

Interesting, do you have the full error log available ?

@deliverymanager
Copy link
Author

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

@deliverymanager
Copy link
Author

I have been using my fork but it is pretty much the same.

@deliverymanager
Copy link
Author

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');
        }
    }

@deliverymanager
Copy link
Author

You also forgot to place the windowsHide to your new chcp command

        return execSync('chcp', { windowsHide: true }).toString().split(':')[1].trim();

@deliverymanager
Copy link
Author

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

@Ekristoffe
Copy link
Contributor

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 ...

@Ekristoffe
Copy link
Contributor

@deliverymanager any news about this problem ?

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

2 participants