NomicFoundation / hardhat-vscode

Solidity and Hardhat support for Visual Studio Code

Home Page:https://hardhat.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Could not send to validation process, uri is not indexed: /home/xxx/1.sol

sentry-io opened this issue · comments

Sentry Issue: VSCODE-EXTENSION-W5V

Reported by @OmarTawfik:

!title:"Error: Could not send to validation process, uri is not indexed and Error: Could not analyze, uri is not indexed. Reading the code, looks to me like it rejects indexing files that are not on disk yet (temporary VS Code editor/buffer?). Since this is also not actionable, should we index the editor in-memory contents? or if non-trivial, should we keep tracking this as an error if it is a known limitation?

We should look again at the check that throw this error. If we do not expect to index in-memory editor files, then we should not report those to sentry - instead checking they are in-memory before hand and avoiding the index lookup. Or if in-memory contents should be in the index, what do we need to change?

Error: Could not send to validation process, uri is not indexed: /home/xxxx/1.sol
  File "/home/xxxx/.config/coc/extensions/node_modules/@nomicfoundation/coc-solidity/node_modules/@nomicfoundation/solidity-language-server/out/index.js", line 2938, in <anonymous>
    '{snip} );if(solFileEntry===void 0)return serverState.logger.error(new Error(`Could not send to validation process, uri is not indexed: ${sourceUri} {snip}
  File "/home/xxxx/.config/coc/extensions/node_modules/@nomicfoundation/coc-solidity/node_modules/@nomicfoundation/solidity-language-server/out/index.js", line 2939, in SentryServerTelemetry.trackTiming
    '{snip} taskName,tags});this.actionTaken=!0;try{let trackingResult=await action(transaction);return transaction.setStatus(trackingResult.status),tra {snip}

@antico5 this is likely new files that have been opened but never saved, so they haven't triggered a create event with a uri, right?

I just tested with new, unsaved files, and we don't get validation on those but we also don't throw any errors. I also tried opening a single file from outside the workspace and it works as expected.

I can't really tell what the reason could be. When a file is requested validation, if it's not present in the index, it is indexed and the process continues.

@antico5 thanks for checking. I suggested that because of this logic in indexSolidityFile() which is called from services/validation/validate.ts:

export async function indexSolidityFile(
serverState: ServerState,
fileUri: string
) {
if (!(await serverState.workspaceFileRetriever.isFile(fileUri))) {
return;
}

And isFile() in turn just checks the local FS:

public async isFile(fsPath: string) {
try {
return (await fs.promises.stat(fsPath)).isFile();
} catch (error) {
return false;
}
}