Skip to content

Error reporting cleanup PR #1#8140

Closed
alcuadrado wants to merge 9 commits intomainfrom
error-reporting-cleanup
Closed

Error reporting cleanup PR #1#8140
alcuadrado wants to merge 9 commits intomainfrom
error-reporting-cleanup

Conversation

@alcuadrado
Copy link
Copy Markdown
Member

@alcuadrado alcuadrado commented Apr 13, 2026

This is the first PR to tackle #8041

It is not complete, but as it changes some linter rules, the sooner we get to merge it, the better.

It has these commits:

  1. dafc4d3: Remove shouldBeReported flags from error descriptors that shouldn't have it.
  2. 81730fa: Enable an eslint rule to force us to always use return await promise instead of return promise.
  3. An autofix of the rule described above.
  4. 026b8cc: Enable an eslint rule that forces every function that returns a promise to be async.
  5. An autofix of the rule described above.
  6. A fix for an unhandled promise.
  7. Changests
  8. Small linter fixes

The reason the eslint rules are added is that v8, and hence Node, reports better error stacks if you await the promises and use async functions instead of sync functions that return promises. It doesn't skip the stack frames like that. It's not perfect, because things like setTimeout()/.then()/etc can still confuse it, but it's a big improvement. Some info here: https://v8.dev/docs/stack-trace-api#async-stack-traces

This may seem random with respect to the error reporting error, but it's important to be able to properly classify what should and should not be reported to sentry.

Copilot AI review requested due to automatic review settings April 13, 2026 22:40
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: fb63e04

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@nomicfoundation/hardhat-ethers-chai-matchers Patch
@nomicfoundation/hardhat-ethers Patch
@nomicfoundation/hardhat-foundry Patch
@nomicfoundation/hardhat-ignition-ethers Patch
@nomicfoundation/hardhat-ignition-viem Patch
@nomicfoundation/hardhat-ignition Patch
@nomicfoundation/hardhat-keystore Patch
@nomicfoundation/hardhat-ledger Patch
@nomicfoundation/hardhat-mocha Patch
@nomicfoundation/hardhat-network-helpers Patch
@nomicfoundation/hardhat-node-test-reporter Patch
@nomicfoundation/hardhat-node-test-runner Patch
@nomicfoundation/hardhat-solx Patch
@nomicfoundation/hardhat-test-utils Patch
@nomicfoundation/hardhat-typechain Patch
@nomicfoundation/hardhat-utils Patch
@nomicfoundation/hardhat-verify Patch
@nomicfoundation/hardhat-viem-assertions Patch
@nomicfoundation/hardhat-viem Patch
hardhat Patch
@nomicfoundation/ignition-core Patch
@nomicfoundation/hardhat-errors Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@alcuadrado alcuadrado added no docs needed This PR doesn't require links to documentation no peer bump needed labels Apr 13, 2026
@alcuadrado alcuadrado force-pushed the error-reporting-cleanup branch from 91a06db to b62fff8 Compare April 13, 2026 22:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is an initial step toward improving error reporting quality (Hardhat issue #8041) by tightening async/await patterns across the codebase so V8/Node produce more informative stack traces, while also cleaning up error reporting metadata.

Changes:

  • Removes shouldBeReported from several error descriptors that shouldn’t be reported to Sentry.
  • Updates the shared ESLint config to enforce @typescript-eslint/promise-function-async and @typescript-eslint/return-await ("always"), then applies broad autofixes across packages.
  • Adds changesets for patch releases reflecting the async-handling improvements.

Reviewed changes

Copilot reviewed 253 out of 255 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/ignition-core/src/track-transaction.ts Uses return await to improve async stack traces during tx tracking.
packages/ignition-core/src/list-deployments.ts Awaits readdir return for clearer async call stacks.
packages/ignition-core/src/internal/wiper.ts Uses return await for message application path.
packages/ignition-core/src/internal/validation/validate.ts Awaits validation helpers per future type for better traces.
packages/ignition-core/src/internal/reconciliation/reconcile-future-specific-reconciliations.ts Awaits per-future reconciliation functions.
packages/ignition-core/src/internal/execution/nonce-management/get-nonce-sync-messages.ts Makes Promise.all mapper async/await for trace consistency.
packages/ignition-core/src/internal/execution/future-processor/helpers/save-artifacts-for-future.ts Awaits artifact persistence helpers.
packages/ignition-core/src/internal/execution/future-processor/helpers/replay-strategy.ts Awaits replay helper calls for better stack frames.
packages/ignition-core/src/internal/execution/future-processor/helpers/network-interaction-execution.ts Awaits client.call to improve stack traces.
packages/ignition-core/src/internal/execution/future-processor/handlers/monitor-onchain-interaction.ts Makes tx-fetch mapping async/await for trace consistency.
packages/ignition-core/src/internal/execution/future-processor/future-processor.ts Awaits strategy/tx/static-call steps.
packages/ignition-core/src/internal/deployment-loader/file-deployment-loader.ts Makes storeNamedArtifact async and awaits delegation.
packages/ignition-core/src/internal/deployment-loader/ephemeral-deployment-loader.ts Awaits artifact resolver result when loading by contract name.
packages/ignition-core/src/deploy.ts Uses return await when delegating to deployer.
packages/hardhat/test/utils.ts Makes mock provider promise-returning methods async.
packages/hardhat/test/test-helpers/create-mock-hardhat-runtime-environment.ts Uses return await around HRE creation in tests.
packages/hardhat/test/internal/example-mock-artifacts-plugin-using-test.ts Makes task action async and awaits artifact read.
packages/hardhat/test/internal/core/tasks/task-manager.ts Makes lazy action loaders async and awaits dynamic imports.
packages/hardhat/test/internal/core/tasks/builders.ts Makes lazy action loader async and awaits dynamic imports.
packages/hardhat/test/internal/core/plugins/resolve-plugin-list.ts Awaits resolvePluginList in reject assertions.
packages/hardhat/test/internal/core/plugins/detect-plugin-npm-dependency-problems.ts Awaits detectPluginNpmDependencyProblems in reject assertions.
packages/hardhat/test/internal/core/hook-manager.ts Makes hook handler imports async/await.
packages/hardhat/test/internal/core/config-validation.ts Awaits HRE creation in helper.
packages/hardhat/test/internal/cli/telemetry/helpers.ts Uses return await new Promise(...) for trace consistency.
packages/hardhat/test/internal/cli/main.ts Wraps calls in async lambdas and awaits for better trace frames.
packages/hardhat/test/internal/cli/init/prompt.ts Awaits prompt helpers inside reject assertions.
packages/hardhat/test/internal/cli/init/init.ts Awaits init helpers inside reject assertions.
packages/hardhat/test/internal/builtin-plugins/test/task-action.ts Awaits next(...) in test hooks for trace consistency.
packages/hardhat/test/internal/builtin-plugins/solidity/tasks/build-cleanup-artifacts.ts Awaits next(...) in solidity hook tests.
packages/hardhat/test/internal/builtin-plugins/solidity/hooks.ts Awaits next(...) in solidity hook tests.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts Awaits default behaviors in resolver hook tests.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/resolver/helpers.ts Awaits project.clean() in async-dispose path.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/partial-compilation/helpers.ts Awaits Promise.all results and various fs helpers.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts Wraps several expected rejects in async/await style.
packages/hardhat/test/internal/builtin-plugins/solidity/build-system/compilation-job.ts Awaits next(...) in hook tests (incl. multiline formatting).
packages/hardhat/test/internal/builtin-plugins/solidity-test/task-action.ts Awaits task runs inside reject assertions.
packages/hardhat/test/internal/builtin-plugins/solidity-test/config-validation.ts Awaits HRE creation in helper.
packages/hardhat/test/internal/builtin-plugins/node/json-rpc/handler.ts Makes Promise.all mappers async/await and handles unsubscribe on ws close.
packages/hardhat/test/internal/builtin-plugins/network-manager/request-handlers/handlers/chain-id/chain-id-handler.ts Awaits handler call in reject assertion.
packages/hardhat/test/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.ts Awaits handler calls in reject assertions.
packages/hardhat/test/internal/builtin-plugins/network-manager/request-handlers/ethereum-mocked-provider.ts Makes mocked provider send async.
packages/hardhat/test/internal/builtin-plugins/network-manager/network-manager.ts Awaits next(...) in hook tests.
packages/hardhat/test/internal/builtin-plugins/network-manager/http-provider.ts Awaits fetch(...) in test override.
packages/hardhat/test/internal/builtin-plugins/network-manager/hook-handlers/network.ts Uses async mapping for Promise.all concurrency test.
packages/hardhat/test/internal/builtin-plugins/flatten/task-action.ts Awaits HRE creation in helper.
packages/hardhat/src/internal/utils/package.ts Makes registry response .then callback async/await for better traces.
packages/hardhat/src/internal/hre-initialization.ts Awaits HardhatRuntimeEnvironmentImplementation.create(...).
packages/hardhat/src/internal/core/user-interruptions.ts Awaits mutex runs and handler chain execution.
packages/hardhat/src/internal/core/tasks/resolved-task.ts Awaits handler-chain next(...) calls.
packages/hardhat/src/internal/core/plugins/resolve-plugin-list.ts Awaits reverseTopologicalSort(...).
packages/hardhat/src/internal/core/hre.ts Awaits project root resolution and hook chains.
packages/hardhat/src/internal/core/hook-manager.ts Awaits next(...), Promise.all handler runs, and plugin hook loading.
packages/hardhat/src/internal/core/configuration-variables.ts Awaits mutex run and hook chain when resolving env vars.
packages/hardhat/src/internal/config-loading.ts Awaits config path normalization and config discovery.
packages/hardhat/src/internal/cli/telemetry/telemetry-permissions.ts Awaits telemetry config check.
packages/hardhat/src/internal/cli/telemetry/sentry/transport.ts Makes transport methods async and consistently awaits promise returns.
packages/hardhat/src/internal/cli/telemetry/sentry/reporter.ts Awaits reportErrorViaSubprocess return.
packages/hardhat/src/internal/cli/telemetry/sentry/anonymizer.ts Uses async mappers and awaits anonymization helpers.
packages/hardhat/src/internal/cli/telemetry/analytics/analytics.ts Awaits analytics send helpers.
packages/hardhat/src/internal/builtin-plugins/test/index.ts Makes hook handler/task action imports async/await.
packages/hardhat/src/internal/builtin-plugins/test/hook-handlers/config.ts Awaits resolveTestUserConfig(...).
packages/hardhat/src/internal/builtin-plugins/telemetry/index.ts Makes task action import async/await.
packages/hardhat/src/internal/builtin-plugins/solidity/solidity-hooks.ts Awaits compiler lookup.
packages/hardhat/src/internal/builtin-plugins/solidity/index.ts Makes hook handler/task action imports async/await.
packages/hardhat/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts Awaits underlying build system calls in lazy wrapper.
packages/hardhat/src/internal/builtin-plugins/solidity/hook-handlers/config.ts Awaits resolveSolidityUserConfig(...).
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts Makes default reader async and awaits default behaviors.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts Awaits mutex operations and internal resolution helpers.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/read-source-file.ts Awaits hook chain and file read in default handler.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.ts Makes remappings reader async and awaits hook chain/default behavior.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.ts Uses return await new Promise(...) for stream read.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts Awaits compiler resolution (path vs version).
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts Awaits exists/mutex usage and json reads/post-processing.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts Awaits preprocess hook chain call.
packages/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts Awaits filesystem scans, hook chains, compiler invocations, and mapping functions.
packages/hardhat/src/internal/builtin-plugins/solidity-test/index.ts Makes hook handler/task action imports async/await.
packages/hardhat/src/internal/builtin-plugins/solidity-test/hook-handlers/test.ts Awaits next(...) in test hook handler.
packages/hardhat/src/internal/builtin-plugins/solidity-test/hook-handlers/config.ts Awaits config resolution helper.
packages/hardhat/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts Awaits Promise.all and artifact reads.
packages/hardhat/src/internal/builtin-plugins/run/index.ts Makes task action import async/await.
packages/hardhat/src/internal/builtin-plugins/node/json-rpc/server.ts Makes listen async and awaits Promise construction.
packages/hardhat/src/internal/builtin-plugins/node/json-rpc/handler.ts Uses async mappers and avoids unhandled unsub rejections.
packages/hardhat/src/internal/builtin-plugins/node/index.ts Makes task action import async/await.
packages/hardhat/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.ts Makes accounts mapping async/await.
packages/hardhat/src/internal/builtin-plugins/network-manager/network-manager.ts Awaits handler chain initialization and provider creation paths.
packages/hardhat/src/internal/builtin-plugins/network-manager/index.ts Makes hook handler imports async/await.
packages/hardhat/src/internal/builtin-plugins/network-manager/http-provider.ts Awaits wrapper calls and retry paths.
packages/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts Awaits next(...) in network hook handler chain.
packages/hardhat/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts Awaits network manager methods in HRE hooks.
packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts Awaits Promise.all of account conversions.
packages/hardhat/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts Awaits mutex run.
packages/hardhat/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts Awaits deepEqual, clientVersion helper, and response handling.
packages/hardhat/src/internal/builtin-plugins/network-manager/base-provider.ts Makes send async and awaits request(...).
packages/hardhat/src/internal/builtin-plugins/gas-analytics/index.ts Awaits runSuper and action import.
packages/hardhat/src/internal/builtin-plugins/flatten/index.ts Makes task action import async/await.
packages/hardhat/src/internal/builtin-plugins/coverage/index.ts Makes hook handler imports async/await.
packages/hardhat/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts Awaits next(...) in coverage hook handler.
packages/hardhat/src/internal/builtin-plugins/console/index.ts Makes task action import async/await.
packages/hardhat/src/internal/builtin-plugins/clean/index.ts Makes task action import async/await.
packages/hardhat/src/internal/builtin-plugins/artifacts/index.ts Makes hook handler import async/await.
packages/hardhat/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts Awaits lazy artifact manager delegates.
packages/hardhat/src/internal/builtin-plugins/artifacts/artifact-manager.ts Makes fs-data reader async and awaits json reads.
packages/hardhat-viem/test/utils.ts Makes mock provider methods async.
packages/hardhat-viem/test/contracts.ts Awaits next(...) in network hook override.
packages/hardhat-viem/src/internal/initialization.ts Makes helper methods async and awaits underlying client helpers.
packages/hardhat-viem/src/internal/clients.ts Awaits wallet client getter.
packages/hardhat-viem/src/index.ts Makes hook handler import async/await.
packages/hardhat-viem-assertions/src/internal/viem-assertions.ts Awaits assertion helpers for consistent async traces.
packages/hardhat-viem-assertions/src/internal/assertions/balances-have-changed.ts Uses async mapper and awaits getBalance calls.
packages/hardhat-viem-assertions/src/index.ts Makes hook handler import async/await.
packages/hardhat-verify/test/utils.ts Makes mock provider methods async.
packages/hardhat-verify/test/tasks/verify/task-action.ts Awaits Promise.resolve paths and verification callback.
packages/hardhat-verify/src/verify.ts Awaits verify(...) call.
packages/hardhat-verify/src/internal/verification.ts Awaits provider instance creation.
packages/hardhat-verify/src/internal/tasks/verify/sourcify/index.ts Makes task action import async/await.
packages/hardhat-verify/src/internal/tasks/verify/index.ts Makes task action import async/await.
packages/hardhat-verify/src/internal/tasks/verify/etherscan/index.ts Makes task action import async/await.
packages/hardhat-verify/src/internal/tasks/verify/blockscout/index.ts Makes task action import async/await.
packages/hardhat-verify/src/internal/sourcify.ts Awaits recursive poll path.
packages/hardhat-verify/src/internal/etherscan.ts Awaits recursive poll path and lazy wrapper delegates.
packages/hardhat-verify/src/internal/contract.ts Awaits resolver branches.
packages/hardhat-verify/src/internal/bytecode.ts Awaits parse call.
packages/hardhat-verify/src/internal/blockscout.ts Awaits recursive poll path.
packages/hardhat-verify/src/index.ts Makes hook handler imports async/await.
packages/hardhat-utils/test/subprocess.ts Uses return await new Promise(...) and awaits subprocess spawns in tests.
packages/hardhat-utils/src/synchronization.ts Awaits Promise construction in mutex acquisition.
packages/hardhat-utils/src/package.ts Awaits getRealPath(...).
packages/hardhat-utils/src/fs.ts Awaits recursive traversal calls.
packages/hardhat-utils/src/eth.ts Adjusts async checksum helpers (see PR comments).
packages/hardhat-typechain/test/index.ts Awaits task run inside reject assertion.
packages/hardhat-typechain/src/index.ts Makes hook handler imports async/await.
packages/hardhat-test-utils/test/hardhat-error.ts Wraps helper usage with async/await in reject assertions.
packages/hardhat-test-utils/src/fixture-projects.ts Awaits realpath resolution.
packages/hardhat-solx/test/integration.ts Awaits HRE creation in test helper.
packages/hardhat-solx/src/internal/solx-compiler.ts Awaits spawn compile.
packages/hardhat-solx/src/internal/hook-handlers/solidity.ts Awaits next(...) when not handling SOLX compiler type.
packages/hardhat-solx/src/index.ts Makes hook handler imports async/await.
packages/hardhat-node-test-runner/src/task-action.ts Awaits getAllFilesMatching(...).
packages/hardhat-node-test-runner/src/index.ts Makes task action and hook handler imports async/await.
packages/hardhat-node-test-runner/src/hookHandlers/test.ts Awaits next(...) in test hook handler.
packages/hardhat-node-test-reporter/integration-tests/fixture-tests/errors-test/test.ts Awaits Promise.any(...) for stack trace improvements.
packages/hardhat-network-helpers/test/time/set-next-block-timestamp.ts Wraps rejects with async/await call sites.
packages/hardhat-network-helpers/test/time/increase.ts Wraps rejects with async/await call sites.
packages/hardhat-network-helpers/test/time/increase-to.ts Wraps rejects with async/await call sites.
packages/hardhat-network-helpers/test/network-helpers/take-snapshot.ts Awaits restore in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-storage-at.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-prevrandao.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-nonce.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-next-block-base-fee-per-gas.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-coinbase.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-code.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-block-gas-limit.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/set-balance.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/mine.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/mine-up-to.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/load-fixture.ts Awaits fixture load in reject assertions.
packages/hardhat-network-helpers/test/network-helpers/impersonate-account.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/get-storage-at.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/network-helpers/drop-transaction.ts Awaits helper call in reject assertion.
packages/hardhat-network-helpers/test/index.ts Makes hook handler import async/await and awaits method calls in rejects.
packages/hardhat-network-helpers/test/helpers/mocked-web3-client-version.ts Awaits next(...) in network hook handler.
packages/hardhat-network-helpers/test/assertions.ts Awaits assertion call sites in reject assertions.
packages/hardhat-network-helpers/src/internal/network-helpers/time/time.ts Awaits helper implementations (increase/latest/etc).
packages/hardhat-network-helpers/src/internal/network-helpers/time/helpers/increase.ts Awaits networkHelpers.time.latest().
packages/hardhat-network-helpers/src/internal/network-helpers/network-helpers.ts Awaits all helper delegations (mine, snapshot, etc).
packages/hardhat-network-helpers/src/index.ts Makes hook handler import async/await.
packages/hardhat-mocha/src/task-action.ts Awaits getAllFilesMatching(...).
packages/hardhat-mocha/src/index.ts Makes task action and hook handler imports async/await.
packages/hardhat-mocha/src/hookHandlers/test.ts Awaits next(...) in test hook handler.
packages/hardhat-ledger/test/mocked-network-plugin.ts Awaits next(...) in mocked network hook.
packages/hardhat-ledger/test/internal/handler.ts Awaits init/handle calls in reject assertions and awaits original transport create.
packages/hardhat-ledger/test/helpers/ethereum-provider-mock.ts Makes mocked provider send async.
packages/hardhat-ledger/src/internal/hook-handlers/network.ts Awaits next(...) in network hook handler.
packages/hardhat-ledger/src/internal/hook-handlers/config.ts Awaits ledger config validation.
packages/hardhat-ledger/src/internal/handler.ts Adds async/await to confirmation/signing/retry paths.
packages/hardhat-ledger/src/index.ts Makes hook handler imports async/await.
packages/hardhat-keystore/test/integration/tasks.ts Wraps task runs in async lambdas and awaits.
packages/hardhat-keystore/test/hook-handlers/configuration-variables.ts Awaits runHandlerChain(...) in reject assertions.
packages/hardhat-keystore/src/internal/loaders/keystore-file-loader.ts Awaits file existence check.
packages/hardhat-keystore/src/internal/loaders/file-manager.ts Makes file manager methods async and awaits fs helpers.
packages/hardhat-keystore/src/internal/keystores/password.ts Makes password handlers async and awaits I/O/inputs.
packages/hardhat-keystore/src/internal/hook-handlers/configuration-variables.ts Awaits next(...) and keystore reads.
packages/hardhat-keystore/src/index.ts Makes hook handler/task action imports async/await.
packages/hardhat-ignition/test/test-helpers/wait-for-pending-txs.ts Makes sleep async and awaits timer promise.
packages/hardhat-ignition/test/test-helpers/use-ignition-project.ts Adds mocha type augmentation import and makes several helpers async/await.
packages/hardhat-ignition/test/test-helpers/test-ignition-helper.ts Awaits conversion to viem contracts.
packages/hardhat-ignition/test/test-helpers/sleep.ts Makes sleep async and awaits timer promise.
packages/hardhat-ignition/test/test-helpers/mine-block.ts Awaits provider request.
packages/hardhat-ignition/test/deploy/build-profile.ts Awaits runSuper(...) in override.
packages/hardhat-ignition/src/internal/tasks/deploy.ts Awaits deployment parameters reads.
packages/hardhat-ignition/src/index.ts Makes config/task action imports async/await.
packages/hardhat-ignition/src/helpers/hardhat-artifact-resolver.ts Awaits build info and makes loadArtifact async.
packages/hardhat-ignition-viem/test/ignition-helper-exclusivity.ts Awaits hre.network.create() in reject assertion callback.
packages/hardhat-ignition-viem/src/internal/viem-ignition-helper.ts Awaits contract conversion helpers.
packages/hardhat-ignition-ethers/test/ignition-helper-exclusivity.ts Awaits hre.network.create() in reject assertion callback.
packages/hardhat-ignition-ethers/test/deploy-with-ethers-result.ts Awaits ignition deploy in reject assertion callback.
packages/hardhat-ignition-ethers/src/internal/ethers-ignition-helper.ts Awaits getContractAt calls.
packages/hardhat-ignition-ethers/src/index.ts Makes hook handler import async/await.
packages/hardhat-foundry/test/integration/solidity-hook.ts Awaits build task run in reject assertion callback.
packages/hardhat-foundry/src/internal/foundry/forge.ts Awaits exists(...).
packages/hardhat-foundry/src/index.ts Makes hook handler import async/await.
packages/hardhat-ethers/test/plugin-functionalities.ts Awaits original provider send call in override.
packages/hardhat-ethers/test/helpers/helpers.ts Uses return await new Promise(...) in sleep helper.
packages/hardhat-ethers/test/contracts.ts Converts event-wait tests to async/await style (see PR comments).
packages/hardhat-ethers/src/internal/signers/signers.ts Makes many Promise-returning methods async and awaits provider operations.
packages/hardhat-ethers/src/internal/signers/populate.ts Awaits resolveProperties(...).
packages/hardhat-ethers/src/internal/signers/derive-private-key.ts Awaits derivePrivateKeysImpl(...).
packages/hardhat-ethers/src/internal/signers/deep-copy.ts Awaits deepClone(...) for arrays.
packages/hardhat-ethers/src/internal/hardhat-helpers/hardhat-helpers.ts Awaits signer/factory/contract helper paths.
packages/hardhat-ethers/src/internal/hardhat-ethers-provider/hardhat-ethers-provider.ts Broad async/await normalization (incl. waitForTransaction path).
packages/hardhat-ethers/src/internal/ethers-utils/ethers-utils.ts Makes Promise.resolve mapping async/await.
packages/hardhat-ethers/src/index.ts Makes hook handler import async/await.
packages/hardhat-ethers-chai-matchers/test/multi-network-connections.ts Wraps tx sends in async callbacks and awaits.
packages/hardhat-ethers-chai-matchers/test/matchers/reverted/revertedWithoutReason.ts Makes assertions async/await where matchers are thenable.
packages/hardhat-ethers-chai-matchers/test/matchers/reverted/revertedWith.ts Makes assertions async/await where matchers are thenable.
packages/hardhat-ethers-chai-matchers/test/matchers/events.ts Wraps some matcher uses in async lambdas and awaits.
packages/hardhat-ethers-chai-matchers/test/matchers/changeTokenBalance.ts Makes tx callback functions async and awaits sends/transfers.
packages/hardhat-ethers-chai-matchers/src/internal/utils/balance.ts Makes getAddresses async and awaits Promise.all.
packages/hardhat-ethers-chai-matchers/src/internal/utils/account.ts Awaits address resolution for addressables.
packages/hardhat-ethers-chai-matchers/src/internal/matchers/withArgs.ts Makes onSuccess async and awaits downstream matcher helpers.
packages/hardhat-ethers-chai-matchers/src/internal/matchers/reverted/revert.ts Awaits provider receipt lookup.
packages/hardhat-ethers-chai-matchers/src/internal/matchers/emit.ts Awaits receipt fetching/waiting and derived promise flow.
packages/hardhat-ethers-chai-matchers/src/internal/matchers/changeTokenBalance.ts Makes balance-change mapping async/await.
packages/hardhat-ethers-chai-matchers/src/internal/matchers/changeEtherBalances.ts Awaits Promise.all fee computations.
packages/hardhat-ethers-chai-matchers/src/internal/hook-handlers/network.ts Awaits next(...) on first network initialization.
packages/hardhat-ethers-chai-matchers/src/index.ts Makes hook handler import async/await.
packages/hardhat-errors/src/descriptors.ts Removes shouldBeReported from selected error descriptors.
packages/config/eslint.config.js Enables promise-function-async and configures return-await to "always".
.changeset/async-improvements-ignition-core.md Patch changeset for ignition-core async/await improvements.
.changeset/async-improvements-hardhat.md Patch changeset for hardhat async/await improvements.
.changeset/async-improvements-hardhat-viem-assertions.md Patch changeset for hardhat-viem-assertions async/await improvements.
.changeset/async-improvements-hardhat-ethers.md Patch changeset for hardhat-ethers async/await improvements.

Comment thread packages/hardhat-utils/src/eth.ts
Comment thread packages/hardhat-ethers/test/contracts.ts
Comment thread packages/hardhat-ignition/test/test-helpers/use-ignition-project.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 254 out of 256 changed files in this pull request and generated 7 comments.

Comment on lines +246 to 249
const incEventPromise = new Promise<void>(async (resolve) => {
listenerInc = resolve;
return contract.on("Inc", listenerInc);
return await contract.on("Inc", listenerInc);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using new Promise(async ...) for the executor. Since contract.on is synchronous, register the listener without await/return inside a normal executor to avoid potential unhandled rejections.

Copilot uses AI. Check for mistakes.
Comment on lines +252 to 255
const anotherEventPromise = new Promise<void>(async (resolve) => {
listenerAnotherEvent = resolve;
return contract.on("AnotherEvent", listenerAnotherEvent);
return await contract.on("AnotherEvent", listenerAnotherEvent);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an async Promise executor here is an anti-pattern and can lead to unhandled rejections if anything throws inside the executor. contract.on is synchronous, so remove await/return and use a non-async executor.

Copilot uses AI. Check for mistakes.
Comment on lines +279 to 287
const incEventPromise = new Promise<void>(async (resolve) => {
listenerInc = () => {
timesCalled++;
if (timesCalled === 2) {
resolve();
}
};
return contract.on("Inc", listenerInc);
return await contract.on("Inc", listenerInc);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid new Promise(async ...) executors; exceptions inside become unhandled rejections rather than rejecting the outer promise. contract.on is synchronous, so use a normal executor and call .on(...) without await/return.

Copilot uses AI. Check for mistakes.
Comment thread packages/hardhat-ethers/test/contracts.ts
Comment on lines +165 to 168
const eventPromise = new Promise(async (resolve) => {
listener = resolve;
return contract.on(contractEvent, resolve);
return await contract.on(contractEvent, resolve);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an async executor in new Promise(async ...) is an anti-pattern and may lead to unhandled rejections if the executor throws. Since contract.on is synchronous, use a non-async executor and call .on(...) without await/return.

Copilot uses AI. Check for mistakes.
Comment thread packages/hardhat-ethers/test/contracts.ts
Comment on lines +214 to 220
const eventPromise = new Promise<void>(async (resolve) => {
listener = () => {
listenerTriggered = true;
resolve();
};
return contract.on("IncBy", listener);
return await contract.on("IncBy", listener);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Promise executor doesn’t need to be async. Making it async can turn thrown errors into unhandled rejections, and contract.on is synchronous so await/return add no value. Prefer a non-async executor and call .on(...) directly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 254 out of 256 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

packages/hardhat-ethers-chai-matchers/test/matchers/reverted/revertedWith.ts:217

  • assertThrows is meant for synchronous exceptions. Passing an async function here will return a Promise instead of throwing synchronously, so the assertion won't work as intended. Make the callback synchronous (remove async/await) if the matcher validates arguments synchronously, or use assertRejects/rejectedWith if it actually returns a rejected Promise.
    packages/hardhat-ethers-chai-matchers/test/matchers/reverted/revertedWith.ts:231
  • Same here: assertThrows won't catch errors from an async callback. This should be a synchronous callback (no async/await) if the error is thrown immediately, otherwise switch this to an async rejection assertion.

Comment on lines +281 to 289
const incEventPromise = new Promise<void>(async (resolve) => {
listenerInc = () => {
timesCalled++;
if (timesCalled === 2) {
resolve();
}
};
return contract.on("Inc", listenerInc);
return await contract.on("Inc", listenerInc);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using an async Promise executor here (new Promise<void>(async (resolve) => ...)). If anything inside the executor throws/rejects, it won't reject incEventPromise, causing unhandled rejections and potential flakiness. Keep the executor synchronous and set up contract.on(...) outside (no await needed for .on).

Copilot uses AI. Check for mistakes.
Comment on lines 122 to 129
it("should fail when used with .not.", async () => {
expect(() =>
expect(contract.emitUint(1))
.not.to.emit(contract, "WithUintArg")
.withArgs(1),
expect(
async () =>
await expect(contract.emitUint(1))
.not.to.emit(contract, "WithUintArg")
.withArgs(1),
).to.throw(Error, "Do not combine .not. with .withArgs()");
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chai.expect(fn).to.throw(...) only asserts synchronous exceptions. Passing an async function here means it returns a Promise and won't throw synchronously, so this test won't validate the intended behavior. Use a non-async callback (no await) if the error is thrown synchronously, or switch to an async rejection assertion (e.g. assertRejects / .to.be.rejectedWith).

Copilot uses AI. Check for mistakes.
Comment on lines 131 to 138
it("should fail when used with .not, subject is a rejected promise", async () => {
expect(() =>
expect(matchers.revertsWithoutReason())
.not.to.emit(contract, "WithUintArg")
.withArgs(1),
expect(
async () =>
await expect(matchers.revertsWithoutReason())
.not.to.emit(contract, "WithUintArg")
.withArgs(1),
).to.throw(Error, "Do not combine .not. with .withArgs()");
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here: .to.throw(...) requires a synchronous throwing function. Wrapping the assertion in async () => await ... prevents the throw from being observed synchronously, so the test can become a false positive/negative. Prefer a sync callback or an async rejection assertion.

Copilot uses AI. Check for mistakes.
Comment on lines +216 to 222
const eventPromise = new Promise<void>(async (resolve) => {
listener = () => {
listenerTriggered = true;
resolve();
};
return contract.on("IncBy", listener);
return await contract.on("IncBy", listener);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using an async function as the executor passed to new Promise(...). Any exception/rejection inside the executor won't be wired to the created Promise, which can lead to unhandled rejections/flaky tests. Here you can keep the Promise executor synchronous and register the contract.on listener outside of it (note that contract.on is synchronous and doesn't need await).

Copilot uses AI. Check for mistakes.
Comment on lines +248 to 251
const incEventPromise = new Promise<void>(async (resolve) => {
listenerInc = resolve;
return contract.on("Inc", listenerInc);
return await contract.on("Inc", listenerInc);
});
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid new Promise<void>(async (resolve) => ...) here. Promise executors should not be async (rejections are not connected to the constructed Promise), and contract.on(...) is synchronous so it shouldn't be awaited/returned from the executor. Create the Promise with a sync executor, and call contract.on(...) separately.

Copilot uses AI. Check for mistakes.
@alcuadrado alcuadrado force-pushed the error-reporting-cleanup branch from 754bbb2 to 7e01656 Compare April 13, 2026 23:55
@alcuadrado
Copy link
Copy Markdown
Member Author

The comments about on and once are incorrect. Copilot doesn't realize that the ethers version of those methods return promises. Oh, ethers...

Copilot AI review requested due to automatic review settings April 14, 2026 01:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 255 out of 257 changed files in this pull request and generated no new comments.

@alcuadrado alcuadrado force-pushed the error-reporting-cleanup branch from 5899486 to fb63e04 Compare April 14, 2026 11:19
@alcuadrado
Copy link
Copy Markdown
Member Author

Replaced with #8148 to avoid having a huge pr

@alcuadrado alcuadrado closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no docs needed This PR doesn't require links to documentation no peer bump needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants