Replace debug package with in-tree createDebug helper#8192
Merged
Conversation
🦋 Changeset detectedLatest commit: dadc2fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
Contributor
hardhatTotal size of the bundle: List of dependencies (sorted by size) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR replaces the external debug npm dependency across the monorepo with an in-tree createDebug logger factory provided by @nomicfoundation/hardhat-utils, aiming to reduce cold-load overhead and speed up the disabled logging path.
Changes:
- Replaced
debugimports/usages withcreateDebug(...)across packages (and updated a few type annotations toDebugLogger). - Removed direct
debug/@types/debugdependencies from multiple package manifests and updatedpnpm-lock.yaml. - Added a new
@nomicfoundation/hardhat-utilsdebug implementation (src/debug.ts+src/internal/debug.ts) and a dedicated test suite.
Reviewed changes
Copilot reviewed 55 out of 58 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Removes direct debug installs and updates snapshots/peer resolutions accordingly. |
| packages/ignition-core/src/internal/execution/future-processor/handlers/monitor-onchain-interaction.ts | Switches onchain interaction monitor logging to createDebug. |
| packages/ignition-core/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat/test/internal/builtin-plugins/console/task-action.ts | Updates tests to use createDebug instead of debug. |
| packages/hardhat/src/internal/config-loading.ts | Migrates config-loading logger to createDebug. |
| packages/hardhat/src/internal/cli/telemetry/telemetry-permissions.ts | Migrates telemetry permissions logger to createDebug. |
| packages/hardhat/src/internal/cli/telemetry/sentry/transport.ts | Migrates sentry transport logger to createDebug. |
| packages/hardhat/src/internal/cli/telemetry/sentry/subprocess.ts | Migrates sentry subprocess logger to createDebug. |
| packages/hardhat/src/internal/cli/telemetry/sentry/reporter.ts | Migrates sentry reporter logger to createDebug. |
| packages/hardhat/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts | Migrates global error handler logger to createDebug. |
| packages/hardhat/src/internal/cli/telemetry/analytics/utils.ts | Migrates analytics utils logger to createDebug. |
| packages/hardhat/src/internal/cli/telemetry/analytics/analytics.ts | Migrates analytics logger to createDebug. |
| packages/hardhat/src/internal/cli/main.ts | Migrates CLI main logger to createDebug and updates logger param typing. |
| packages/hardhat/src/internal/cli/init/init.ts | Migrates init flow logger to createDebug. |
| packages/hardhat/src/internal/cli/banner-manager.ts | Migrates banner manager logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts | Migrates compiler index logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts | Migrates compiler downloader logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/solidity/build-system/build-system.ts | Migrates build system logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/node/task-action.ts | Migrates node task logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/node/json-rpc/server.ts | Migrates JSON-RPC server logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/node/helpers.ts | Updates logger parameter type to DebugLogger. |
| packages/hardhat/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts | Migrates build-info watcher logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.ts | Migrates trace output logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts | Migrates EDR provider logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts | Migrates gas analytics debug logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts | Migrates coverage hook handler logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/coverage/coverage-manager.ts | Migrates coverage manager logger to createDebug. |
| packages/hardhat/src/internal/builtin-plugins/console/task-action.ts | Migrates console task logger to createDebug. |
| packages/hardhat/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-verify/src/internal/metadata.ts | Migrates verify metadata logger to createDebug. |
| packages/hardhat-verify/src/internal/etherscan.ts | Migrates etherscan logger to createDebug. |
| packages/hardhat-verify/src/internal/blockscout.ts | Migrates blockscout logger to createDebug. |
| packages/hardhat-verify/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-vendored/package.json | Drops @types/debug devDependency. |
| packages/hardhat-utils/test/debug.ts | Adds unit tests for createDebug + pattern parsing + color behavior. |
| packages/hardhat-utils/src/synchronization.ts | Migrates mutex logging to use the in-package createDebug. |
| packages/hardhat-utils/src/internal/debug.ts | Introduces internal helpers for pattern parsing, enable checks, and color selection. |
| packages/hardhat-utils/src/debug.ts | Implements createDebug and defines the exported DebugLogger type. |
| packages/hardhat-utils/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-typechain/src/internal/generate-types.ts | Migrates typechain logger to createDebug. |
| packages/hardhat-typechain/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-solx/src/internal/hook-handlers/solidity.ts | Migrates solx hook handler logger to createDebug. |
| packages/hardhat-solx/src/internal/hook-handlers/config.ts | Migrates solx config hook logger to createDebug. |
| packages/hardhat-solx/src/internal/downloader.ts | Migrates solx downloader logger to createDebug. |
| packages/hardhat-solx/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-network-helpers/package.json | Drops @types/debug devDependency. |
| packages/hardhat-mocha/src/task-action.ts | Migrates performance logger to createDebug. |
| packages/hardhat-mocha/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-ledger/src/internal/handler.ts | Migrates ledger handler logger to createDebug. |
| packages/hardhat-ledger/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-keystore/src/internal/hook-handlers/config.ts | Migrates keystore config hook logger to createDebug. |
| packages/hardhat-keystore/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-ignition/src/internal/utils/load-module.ts | Migrates ignition module loader logger to createDebug. |
| packages/hardhat-ignition/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-ethers/src/internal/hardhat-ethers-provider/hardhat-ethers-provider.ts | Migrates ethers provider logger to createDebug. |
| packages/hardhat-ethers/package.json | Drops debug and @types/debug dependencies. |
| packages/hardhat-ethers-chai-matchers/package.json | Drops @types/debug devDependency. |
| .changeset/full-otters-say.md | Adds a changeset describing the performance improvement and patch bumps. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
alcuadrado
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Replaces the
debugnpm dependency across the monorepo withcreateDebug, a small zero-dependency logger factory that lives in@nomicfoundation/hardhat-utils.It keeps the same call-site shape (
const log = createDebug("namespace")) and the sameDEBUGfilter syntax, while adding a faster disabled-emit path (NOOPshort-circuit) and a richer 49-color palette that makes namespaces easier to distinguish.Review notes:
Closes #8161.
Differences against
debugDEBUGandDEBUG_COLORSenv vars are honoured; others (e.g.DEBUG_DEPTH,DEBUG_HIDE_DATE) are ignored.enable()/disable().debug@4defaults to 6 colors and only upgrades to a 76-color palette when supports-color detects a 256-color terminal. This is fine for most modern terminals, and older ones fall back to the closest supported color.DEBUG_COLORS=no(only the ANSI codes change).debugswitches to a different layout (with an ISO timestamp prefix) when colours are disabled.+123ms, not humanized to+1s/+2m..enabled; noextend,namespace, or customformatters.Tests
DEBUG='hardhat:*' pnpm hardhat testoutput against an unmodifieddebug-based build on the same project. Per-line+Nmsmarkers matched within normal run-to-run noise, from sub-ms differences to about 7 ms on individual steps. No regressions were observed that could be attributed tohardhat-utils/debug.packages/example-project:%O,.enabled, multi-arg, deferred logging) without the CLI:Benchmark
Compared
createDebugagainstdebug@4on the four paths that matter inside the Hardhat monorepo.debug@4createDebug%O)The 3.4× disabled-emit speedup is the most relevant result. That’s the path hit ~150× per CLI command in production.
createDebugreturns a sharedNOOPfor disabled namespaces, whiledebug@4still goes through its wrapperand
enabledcheck on every call.Cold load improves by ~1.6 ms on first import, mainly from avoiding the
msdependency and keeping the implementation small.The enabled-emit improvements come from using
util.formatWithOptions(C++) instead of the JS formatter used indebug@4.