Skip to content

fix: add timeout to registryValidation to prevent CLI hang (#2027)#2062

Closed
justintadair-debug wants to merge 2 commits intoasyncapi:masterfrom
justintadair-debug:fix/registry-timeout-2027
Closed

fix: add timeout to registryValidation to prevent CLI hang (#2027)#2062
justintadair-debug wants to merge 2 commits intoasyncapi:masterfrom
justintadair-debug:fix/registry-timeout-2027

Conversation

@justintadair-debug
Copy link

Summary

When --registry-url points to an unreachable URL (e.g., firewall drops packets), the CLI hangs indefinitely because fetch() has no timeout.

Changes

  • Added AbortController with 5-second timeout
  • Changed GET to HEAD for lighter validation (no body transfer needed)
  • Preserved original error message for debugging
  • Added specific timeout error message
  • Added unit tests for the registry validation function

Before

asyncapi generate fromTemplate spec.yaml @asyncapi/html-template --registry-url http://unreachable:9999
# CLI hangs forever

After

asyncapi generate fromTemplate spec.yaml @asyncapi/html-template --registry-url http://unreachable:9999
# Error: Registry URL timed out after 5 seconds: http://unreachable:9999

Fixes #2027

/attempt #2027

…2027)

When --registry-url points to an unreachable URL (e.g., firewall drops
packets), the CLI hangs indefinitely because fetch() has no timeout.

This fix:
- Adds AbortController with 5-second timeout
- Changes GET to HEAD for lighter validation
- Preserves original error message for debugging
- Adds specific timeout error message

Fixes asyncapi#2027
@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 87dec03

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

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli 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

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarqubecloud
Copy link

@github-project-automation github-project-automation bot moved this from To Triage to Done in CLI - Kanban Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] CLI hangs indefinitely when --registry-url points to an unreachable host (no timeout handling)

2 participants