fix: suppress anonymous metrics submission after fatal generation errors#2069
Closed
chengyixu wants to merge 1 commit intoasyncapi:masterfrom
Closed
fix: suppress anonymous metrics submission after fatal generation errors#2069chengyixu wants to merge 1 commit intoasyncapi:masterfrom
chengyixu wants to merge 1 commit intoasyncapi:masterfrom
Conversation
When a fatal error occurred (e.g. non-empty output directory), the CLI attempted to flush metrics and printed an unrelated 'Skipping submitting anonymous metrics due to …' error to stdout, polluting the output. Metrics are now skipped entirely when the command exits with an error. Fixes asyncapi#2010
🦋 Changeset detectedLatest commit: f29f0c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Author
|
Hi @asyncapi/cli-maintainers! All CI checks are passing for this PR. Happy to make any adjustments needed for merge. Thanks! |
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.



Summary
Fixes #2010 — When a fatal generation error occurs (e.g. non-empty output directory), the CLI attempted to flush anonymous metrics and printed an unrelated error to stdout:
The second line is confusing — it looks like a second failure but it's just a metrics network call that failed during the error path.
Root Cause
finally()inbase.tsis always called by oclif, even after fatal errors. It unconditionally calledrecordActionFinished(), which tried to flush metrics to the network. When that network call failed (e.g. in CI or offline), the error was caught and printed to stdout, polluting the user-facing error output.Fix
Skip metrics submission entirely when
erroris defined (i.e. the command exits with a fatal error):This is correct behaviour — the
metricsMetadata['success']is still set tofalsebefore the early return (for consistency), but no network call is made.Changes
src/apps/cli/internal/base.ts: GuardrecordActionFinished()with an early return whenerroris definedTest Plan
asyncapi generate asyncapi.yaml @asyncapi/html-template --output ./non-empty-dirno longer prints the metrics error message🤖 Generated with Claude Code