Skip to content

fix(registry): add timeout and use HEAD request in registryValidation#2087

Open
sungdark wants to merge 2 commits intoasyncapi:masterfrom
sungdark:fix/registry-timeout-2027
Open

fix(registry): add timeout and use HEAD request in registryValidation#2087
sungdark wants to merge 2 commits intoasyncapi:masterfrom
sungdark:fix/registry-timeout-2027

Conversation

@sungdark
Copy link
Copy Markdown

Description

Fixes #2027 - CLI hangs indefinitely when --registry-url points to an unreachable host (no timeout handling).

Changes

  • Add AbortController with 5s timeout to prevent indefinite hangs when registry is unreachable
  • Use HEAD request instead of GET for lighter network footprint
  • Meaningful timeout error message: Registry URL timed out after 5s: <url>. The host is unreachable or too slow.
  • Unit tests added for registryURLParser and registryValidation including timeout behavior

Root Cause

The original registryValidation() in src/utils/generate/registry.ts called fetch() without:

  • No AbortController / timeout
  • No signal to abort
  • Used default GET (downloads full response body unnecessarily)
  • Error message was opaque

Testing

# Before fix — hangs indefinitely:
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --registry-url http://10.255.255.1

# After fix — fails fast with clear message:
# Error: Registry URL timed out after 5s: http://10.255.255.1. The host is unreachable or too slow.

Files Changed

  • src/utils/generate/registry.ts — add timeout, use HEAD, proper error messages
  • test/unit/utils/registry.test.ts — new unit tests

sungdark added 2 commits March 25, 2026 15:29
Fixes asyncapi#2027

- Added AbortController with 10 second timeout to prevent indefinite hangs
- Changed from GET to HEAD request for lighter weight validation
- Improved error messages to preserve original error and indicate timeout
Fixes asyncapi#2027 - CLI hangs indefinitely when --registry-url points to
an unreachable host (no timeout handling).

Changes:
- Add AbortController with 5s timeout to prevent indefinite hangs
- Use HEAD request instead of GET for lighter network footprint
- Provide meaningful error message on timeout (shows URL and timeout)
- Add unit tests for registryURLParser and registryValidation
- Test timeout behavior against blackhole IP (10.255.255.1)
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 28, 2026

⚠️ No Changeset found

Latest commit: b25fda3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

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)

1 participant