vscode-solidity: Visual Studio Code: The Solidity Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted

I am working on Win10 and getting this error from VSCode after installing the Solidity extension and then opening a .sol file:


[Error - 14:16:07] (node:10264) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Path must be a string. Received null
[Error - 14:16:07] (node:10264) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\node_modules\solc\soljson.js:1
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path")

TypeError: Path must be a string. Received null
    at assertPath (path.js:7:11)
    at Object.join (path.js:468:7)
    at createPackage (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\projectService.js:12:35)
    at createProjectPackage (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\projectService.js:87:26)
    at Object.initialiseProject (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\projectService.js:33:26)
    at SolcCompiler.compileSolidityDocumentAndGetDiagnosticErrors (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\solcCompiler.js:108:87)
    at validate (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\server.js:36:52)
    at Timeout.setTimeout [as _onTimeout] (C:\Users\user\.vscode\extensions\JuanBlanco.solidity-0.0.27\out\src\server.js:125:26)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
[Error - 14:16:09] Connection to server got closed. Server will not be restarted.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 76 (43 by maintainers)

Commits related to this issue

Most upvoted comments

@jsjoeio Ahh now I understand, also I missed the link!! (doh!) Thanks

This is happening again with vscode@1.45.1 and vscode-solidity@0.0.73 on my macOS@10.15.4:

Capture d’écran 2020-05-26 à 00 55 50

My settings:

{
  "solidity.compileUsingRemoteVersion": "0.6.8+commit.0bbfe453",
  "solidity.enableLocalNodeCompiler": false,
  "solidity.packageDefaultDependenciesContractsDirectory": "",
  "solidity.packageDefaultDependenciesDirectory": "node_modules"
}

Hey @jsjoeio dont worry, language server error can mean anything. So here is a good place. Have you got some sample code, that you can share? Ill test it with Open VSX

can you do me a favor and use this as your settings (global) and remove the workspace ones.

{
    "solidity.compileUsingRemoteVersion": "v0.5.17+commit.d19bba13",
    "solidity.enableLocalNodeCompiler": false,
    "solidity.linter": "solhint",
    "solidity.solhintRules": {
    "avoid-sha3": "error",
    "no-inline-assembly": "warn"
    }
}

and use this contract only

// https://eips.ethereum.org/EIPS/eip-20
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;

contract ERC20Token{

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

    uint256 constant private MAX_UINT256 = 2**256 - 1;
    mapping (address => uint256) public balances;
    mapping (address => mapping (address => uint256)) public allowed;
    uint256 public totalSupply;
    /*
    NOTE:
    The following variables are OPTIONAL vanities. One does not have to include them.
    They allow one to customise the token contract & in no way influences the core functionality.
    Some wallets/interfaces might not even bother to look at this information.
    */
    string public name;                   //fancy name: eg Simon Bucks
    uint8 public decimals;                //How many decimals to show.
    string public symbol;                 //An identifier: eg SBX

    constructor(uint256 _initialAmount, string memory _tokenName, uint8 _decimalUnits, string  memory _tokenSymbol) public {
        balances[msg.sender] = _initialAmount;               // Give the creator all initial tokens
        totalSupply = _initialAmount;                        // Update total supply
        name = _tokenName;                                   // Set the name for display purposes
        decimals = _decimalUnits;                            // Amount of decimals for display purposes
        symbol = _tokenSymbol;                               // Set the symbol for display purposes
    }

    
    function transfer(address _to, uint256 _value) public  returns (bool success) {
        require(balances[msg.sender] >= _value, "token balance is lower than the value requested");
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        uint256 allowance = allowed[_from][msg.sender];
        require(balances[_from] >= _value && allowance >= _value, "token balance or allowance is lower than amount requested");
        balances[_to] += _value;
        balances[_from] -= _value;
        if (allowance < MAX_UINT256) {
            allowed[_from][msg.sender] -= _value;
        }
        emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];
    }

    function approve(address _spender, uint256 _value) public returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }
}

also what version of the extension you have it should be 102. edit you will need to restart… but you should not be getting any errors.

THANK VERY MUCH! Muchas gracias, saludos desde Peru!

whoa! pure magic! i made all the steps you proposed and it works like a charm on all files. BUT those settings were exactly as mine but for one thing: “solidity.enableLocalNodeCompiler”: false was in the end of the settings file. i don’t think this should matter though. also, the failure was in different workspaces so i believe it also doesn’t have to do anything with the workspace settings. maybe it is cache problem or something, i don’t have any other explanation. i’ve also tried to break it changing settings forth and back - no way, it is stable now. so many thanks to you @juanfranblanco !

can you do me a favor and use this as your settings (global) and remove the workspace ones.

{
    "solidity.compileUsingRemoteVersion": "v0.5.17+commit.d19bba13",
    "solidity.enableLocalNodeCompiler": false,
    "solidity.linter": "solhint",
    "solidity.solhintRules": {
    "avoid-sha3": "error",
    "no-inline-assembly": "warn"
    }
}

and use this contract only


// https://eips.ethereum.org/EIPS/eip-20
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;

contract ERC20Token{

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

    uint256 constant private MAX_UINT256 = 2**256 - 1;
    mapping (address => uint256) public balances;
    mapping (address => mapping (address => uint256)) public allowed;
    uint256 public totalSupply;
    /*
    NOTE:
    The following variables are OPTIONAL vanities. One does not have to include them.
    They allow one to customise the token contract & in no way influences the core functionality.
    Some wallets/interfaces might not even bother to look at this information.
    */
    string public name;                   //fancy name: eg Simon Bucks
    uint8 public decimals;                //How many decimals to show.
    string public symbol;                 //An identifier: eg SBX

    constructor(uint256 _initialAmount, string memory _tokenName, uint8 _decimalUnits, string  memory _tokenSymbol) public {
        balances[msg.sender] = _initialAmount;               // Give the creator all initial tokens
        totalSupply = _initialAmount;                        // Update total supply
        name = _tokenName;                                   // Set the name for display purposes
        decimals = _decimalUnits;                            // Amount of decimals for display purposes
        symbol = _tokenSymbol;                               // Set the symbol for display purposes
    }

    
    function transfer(address _to, uint256 _value) public  returns (bool success) {
        require(balances[msg.sender] >= _value, "token balance is lower than the value requested");
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        uint256 allowance = allowed[_from][msg.sender];
        require(balances[_from] >= _value && allowance >= _value, "token balance or allowance is lower than amount requested");
        balances[_to] += _value;
        balances[_from] -= _value;
        if (allowance < MAX_UINT256) {
            allowed[_from][msg.sender] -= _value;
        }
        emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];
    }

    function approve(address _spender, uint256 _value) public returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
        return true;
    }

    function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }
}

also what version of the extension you have it should be 102. edit you will need to restart… but you should not be getting any errors.

Closing this, now although something will cause the server to crash in the future.

@gitpusha I never use that as I work with vscode + visual studio, so no idea.

It seems that you are trying to apply a setting without opening the right folder. You can apply it globally that is normally the case.

@gitpusha you need to provide the full version of the compiler. Like "solidity.compileUsingLocalVersion": "v0.5.17+commit.d19bba13" The best thing is to change it using the context menu, select workspace (current project) or global (all projects) image

Thanks Toca, it’s working fine now. Thanks for your prompt reply too!

Hi Juan (tocayo!),

To compile using the local version you need to provide a full path to the compiler file. Mainly this is used when you have downloaded a version of solc js, and kept in your hard drive.

Thanks is the plugins section in solhint that is causing the crash, I will be releasing a new version today which checks for this.

Hi! Experiencing issue with VSC 1.42.1 & solididy extension 0.0.70 in linux machine when: File > Add Folder to workspace . Notice folder contains several other folders and files.

After restarting VSC message no longer appears.

Workaround: open a folder, instead of just a file. (Thanks)