Skip to content

fix: add timeout handling to registryValidation to prevent CLI hang#2096

Open
TeapoyY wants to merge 1 commit intoasyncapi:masterfrom
TeapoyY:fix/registry-timeout
Open

fix: add timeout handling to registryValidation to prevent CLI hang#2096
TeapoyY wants to merge 1 commit intoasyncapi:masterfrom
TeapoyY:fix/registry-timeout

Conversation

@TeapoyY
Copy link
Copy Markdown

@TeapoyY TeapoyY commented Mar 31, 2026

When --registry-url points to an unreachable host, the CLI would hang indefinitely due to fetch() having no timeout.

Changes

  • Adds AbortController with a 5-second timeout
  • Uses clearTimeout to avoid memory leaks on successful fetch
  • Provides a clear error message when timeout occurs
  • Properly propagates the original error when fetch fails for other reasons

Testing

Tested manually with unreachable registry URL (blackholed IP):
\
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --registry-url http://10.255.255.1
\
Expected: CLI fails fast with timeout error message
Before: CLI hangs indefinitely

Fixes #2027

When --registry-url points to an unreachable host, the CLI would hang
indefinitely due to fetch() having no timeout. This fix:

- Adds AbortController with a 5-second timeout
- Uses clearTimeout to avoid memory leaks on successful fetch
- Provides a clear error message when timeout occurs
- Properly propagates the original error when fetch fails for other reasons

Fixes asyncapi#2027
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

⚠️ No Changeset found

Latest commit: bdc7dc7

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