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

unlockaccount spawns many nodejs defunct processes #1212

Closed
aas312 opened this issue Dec 6, 2017 · 1 comment
Closed

unlockaccount spawns many nodejs defunct processes #1212

aas312 opened this issue Dec 6, 2017 · 1 comment
Assignees
Labels
1.x 1.0 related issues Enhancement Includes improvements or optimizations Stale Has not received enough activity
Projects

Comments

@aas312
Copy link

aas312 commented Dec 6, 2017

I am getting a lot of [nodejs] [defunct] process when run this code. Is there a way to check if an account is already unlocked or lock the account to properly close the nodejs process it starts so that there are not too many nodejs defunct processes.

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
let txHashArray = [];

try {
    if (web3.isConnected()) {
        
        const abi = '[{"constant":false,"inputs":[{"name":"_int","type":"uint16"}],"name":"set","outputs":[{"name":"arrayLength","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"length","outputs":[{"name":"arrayLength","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]';
        const contract = web3.eth.contract(JSON.parse(abi));
        const contractAddress = '0x4D0f2e99a871A276da395538C8107275C17bCe12';
        contractInstance = contract.at();
        
        for (let i = 0; i < 1000; i++) {
            web3.personal.unlockAccount(web3Config.defaultAccount,
                web3Config.defaultAccountPwd);
            /*
            
            const txHash = contractInstance.set(i,{from:web3Config.defaultAccount, gas:'9040000', gasPrice:'0'});
            
            txHashArray.push(txHash);         
            */
           
            console.log(i)
        }
        /*
        // Write txHash to file to check later
        var txfile = fs.createWriteStream('txfile.csv');
        txfile.on('error', function(err) { /* error handling */ });
        txHashArray.forEach(function(v) { 
            txfile.write(v + '\n'); 
        });
        txfile.end();
        */
        
    } else {
        console.log('web3 is not connected');
    }
} catch (error) {
    console.error(error);
}
@aas312 aas312 changed the title unlockaccount spawsn many nodejs defunct processes unlockaccount spawns many nodejs defunct processes Dec 6, 2017
@nivida nivida self-assigned this Aug 9, 2018
@nivida nivida added the Enhancement Includes improvements or optimizations label Nov 29, 2018
@nivida nivida added this to To do in 1.0 Nov 29, 2018
@nivida nivida added the 1.x 1.0 related issues label Jun 20, 2019
@github-actions
Copy link

github-actions bot commented Jul 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Enhancement Includes improvements or optimizations Stale Has not received enough activity
Projects
No open projects
1.0
  
Backlog
Development

No branches or pull requests

2 participants