Skip to content

perf(cli): Replace consola with a small in-house logger - #1771

Merged
BYK merged 1 commit into
mainfrom
perf/cli-drop-consola
Oct 31, 2026
Merged

BYK merged 1 commit into
mainfrom
perf/cli-drop-consola

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #1769.

consola was the largest third-party package in dist/complete.cjs, which sentry __complete loads on every TAB press. The CLI used only a small part of it: levels, tags, the fancy stderr layout, Sentry log forwarding, and confirm/text prompts. This PR replaces it with a small logger in src/lib/logger.ts.

Measured on Node 22 in a dev sandbox, so treat these as rough numbers:

before after
dist/complete.cjs 321.7 KB 249.4 KB
require("./dist/complete.cjs") (median of 30) ~33 ms ~17 ms
node dist/bin.cjs __complete issue "" wall time (median of 30) ~59 ms ~44 ms
dist/index.cjs 7311 KB 7292 KB

Alternatives considered. No off-the-shelf logger came out lighter for what the CLI needs. Bundled and minified: @logtape/logtape ~68 KB, tslog ~68 KB, pino ~61 KB, signale ~49 KB. loglevel (~3 KB) has no tags and no reporter hook. None of them has a Sentry integration that keeps the current consola.* log attributes. The new logger needs only node:util and node:path.

What stays the same

  • Output: the same icons, WARN/ERROR badges, right-aligned tag HH:MM:SS (still from formatLogTime), and plain [type] [tag] message lines in CI and tests. With colors forced in a 120-column PTY, sentry auth status warning output is byte-identical to the old build.
  • Sentry forwarding: log records keep consola's { date, args, type, level, tag } shape, so Sentry.createConsolaReporter() still works and still sets the consola.tag/consola.type/consola.level attributes.
  • Errors passed to the logger render as message, stack frames, and causes, as before. Their other properties, which can hold API response details, are still left out.
  • All loggers share one level and one reporter list, so the withTag registry that setLogLevel needed is gone.

Behavior changes

  • Ctrl+C on a prompt now returns clack's cancel symbol. consola 3.4 returned initial on cancel. So Ctrl+C on "Import from .sentryclirc?" or the Seer trial prompt (both initial: true) counted as yes. Every caller already checks === true or typeof === "string" and its comments expect the symbol, so cancelling now really cancels.
  • Prompts call @clack/prompts directly through a lazy import. It was already in the main bundle, and the SENTRY_CLI_COMPLETION_BUILD define drops it from complete.cjs.
  • Dropped consola features the CLI did not rely on: repeated-message throttling ((repeated N times)), the stack trace consola appended to trace lines in the fancy layout, and box/ready/fatal/verbose/raw. Line width is now measured without string-width, so wide characters count as one column. The only visible effect is that the right-aligned tag can move by one column.

via @BYK.

--

View Session in Sentry

consola was ~75 KB of the ~320 KB `dist/complete.cjs` bundle that
`sentry __complete` loads on every TAB press. The CLI used only levels,
tags, the fancy stderr layout, Sentry log forwarding, and two prompt types.

The new logger keeps consola's output layout and log record shape, so
`Sentry.createConsolaReporter()` still forwards logs. Prompts call
`@clack/prompts` directly and load only when asked, and the completion
bundle drops them. Ctrl+C on a prompt now returns clack's cancel symbol,
which callers already expect, instead of the initial value.

Fixes #1769

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@vercel

vercel Bot commented Oct 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 31, 2026 3:05pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 31, 2026

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! File an issue to release this as a standalone package

@BYK
BYK enabled auto-merge (squash) October 31, 2026 15:17
@BYK
BYK merged commit 2222748 into main Oct 31, 2026
42 checks passed
@BYK
BYK deleted the perf/cli-drop-consola branch October 31, 2026 15:19
sentry-junior Bot added a commit that referenced this pull request Oct 31, 2026
Brings in #1771 (in-house logger replacing consola). The one conflict is
`preloadProjectContext`, which this branch moved to `lib/project-context.ts`;
#1771's comment update is applied there.

This branch was previously deployed

1 inactive deployment
Preview — 47b86340 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Research lighter alternatives to consola in the CLI

1 participant