Skip to content

Conversation

@antico5
Copy link
Collaborator

@antico5 antico5 commented Nov 17, 2025

If you compile a hardhat3 project, cache entries will be set for the contracts that were compiled successfully. When attempting validation for a file, getCompilationJobs is used, which returns an empty array if there are no jobs to compile (because there was a cache hit). Two possible options would be to either skip validation when there are no jobs to compile, or to pass force: true. I chose the latter one since I think it's consistent with our model of compiling on every file change.

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Nov 17, 2025
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.93%. Comparing base (fa4e11f) to head (da7682b).
⚠️ Report is 5 commits behind head on development.

Files with missing lines Patch % Lines
...src/frameworks/Hardhat/Hardhat3/Hardhat3Project.ts 20.00% 4 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #715      +/-   ##
===============================================
+ Coverage        52.61%   52.93%   +0.32%     
===============================================
  Files              231      231              
  Lines             5592     5728     +136     
  Branches           878      918      +40     
===============================================
+ Hits              2942     3032      +90     
- Misses            2392     2427      +35     
- Partials           258      269      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@antico5 antico5 requested a review from kanej November 17, 2025 13:33
@alcuadrado
Copy link
Member

alcuadrado commented Nov 19, 2025

I think this is only part of the problem, because the logs seem to indicate that something else is going off. Look at this.

New project, viem sample project. I open the first Solidity file. I get this log:

Info  - 1:24:10 PM] Solidity by Nomic Foundation Starting ...
[Info  - 1:24:10 PM] env: production
[Info  - 1:24:10 PM] Client starting
[Info  - 1:24:10 PM] Language server starting
[Info  - 1:24:10 PM]   Release: [email protected]
[Info  - 1:24:10 PM]   Environment: production
[Info  - 1:24:10 PM]   Client: Visual Studio Code
[Info  - 1:24:10 PM]   Client Version: 1.106.0
[Info  - 1:24:10 PM]   Telemetry Enabled: true
[Info  - 1:24:10 PM]   Telemetry Tracking Id: e536636e70...
[Info  - 1:24:10 PM]   Workspace Folders:
[Info  - 1:24:10 PM]     npmproject-35 (file:///workspaces/npmprojects/npmproject-35)
[Info  - 1:24:10 PM] Fetching latest solidity versions
[Info  - 1:24:11 PM] Language server ready
[Info  - 1:24:11 PM] [indexing] Found projects:
[Info  - 1:24:11 PM] [indexing] -  Type: Hardhat 3
[Info  - 1:24:11 PM] [indexing]    Base path: /workspaces/npmprojects/npmproject-35
[Info  - 1:24:11 PM] [indexing]    Config file: /workspaces/npmprojects/npmproject-35/hardhat.config.ts
[Info  - 1:24:11 PM] [indexing] Initializing /workspaces/npmprojects/npmproject-35/hardhat.config.ts
[Info  - 1:24:12 PM] [indexing] Done /workspaces/npmprojects/npmproject-35/hardhat.config.ts
[Info  - 1:24:12 PM] [indexing] Scanning workspace folders for sol files
[Info  - 1:24:12 PM] [indexing] Scan complete, 38 sol files found
[Info  - 1:24:12 PM] [indexing] Analyzing 2 solidity files
[Info  - 1:24:14 PM] [indexing] Finished analyzing

I close the file, clear the log, npx hardhat build, open the file:

[Error - 1:26:01 PM] [npmproject-35] Path /workspaces/npmprojects/npmproject-35/artifacts/contracts/Counter.sol is a directory
[Error - 1:26:01 PM] [npmproject-35] IsDirectoryError: Path /workspaces/npmprojects/npmproject-35/artifacts/contracts/Counter.sol is a directory
    at readUtf8File (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/hardhat-utils/dist/src/fs.js:297:19)
    at async next (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/core/hook-manager.js:61:19)
    at async next (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/core/hook-manager.js:60:19)
    at async #readFileContent (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js:742:22)
    at async #buildResolvedFile (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js:617:25)
    at async #resolveProjectFile (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js:153:30)
    at async AsyncMutex.exclusiveRun (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/hardhat-utils/dist/src/synchronization.js:156:20)
    at async /home/vscode/.vscode-server/extensions/nomicfoundation.hardhat-solidity-0.8.25/server/out/index.js:717890:29
    at async AsyncMutex.exclusiveRun (/home/vscode/.vscode-server/extensions/nomicfoundation.hardhat-solidity-0.8.25/server/out/index.js:717846:14)
    at async LSPDependencyGraph.addNewFile (/home/vscode/.vscode-server/extensions/nomicfoundation.hardhat-solidity-0.8.25/server/out/index.js:717953:5)
[Error - 1:26:03 PM] [npmproject-35] Path /workspaces/npmprojects/npmproject-35/cache/test-artifacts/contracts/Counter.t.sol is a directory
[Error - 1:26:03 PM] [npmproject-35] IsDirectoryError: Path /workspaces/npmprojects/npmproject-35/cache/test-artifacts/contracts/Counter.t.sol is a directory
    at readUtf8File (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/hardhat-utils/dist/src/fs.js:297:19)
    at async next (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/core/hook-manager.js:61:19)
    at async next (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/core/hook-manager.js:60:19)
    at async #readFileContent (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js:742:22)
    at async #buildResolvedFile (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js:617:25)
    at async #resolveProjectFile (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/[email protected]/node_modules/hardhat/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js:153:30)
    at async AsyncMutex.exclusiveRun (file:///workspaces/npmprojects/npmproject-35/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/hardhat-utils/dist/src/synchronization.js:156:20)
    at async /home/vscode/.vscode-server/extensions/nomicfoundation.hardhat-solidity-0.8.25/server/out/index.js:717890:29
    at async AsyncMutex.exclusiveRun (/home/vscode/.vscode-server/extensions/nomicfoundation.hardhat-solidity-0.8.25/server/out/index.js:717846:14)
    at async LSPDependencyGraph.addNewFile (/home/vscode/.vscode-server/extensions/nomicfoundation.hardhat-solidity-0.8.25/server/out/index.js:717953:5)

Some part of the language server is treating artifacts/contracts/Counter.sol as a file, not a directory, and it fails. That's not a caching bug.

@antico5
Copy link
Collaborator Author

antico5 commented Nov 20, 2025

@alcuadrado good catch, just pushed a commit to fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:ready This issue is ready to be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants