fix: add timeout to registry validation to prevent indefinite hang#2054
fix: add timeout to registry validation to prevent indefinite hang#2054chengyixu wants to merge 2 commits intoasyncapi:masterfrom
Conversation
…syncapi#2027) - Add AbortController with 5-second timeout to registryValidation() - Switch from GET to HEAD for lightweight registry reachability check - Provide specific error messages for timeout vs general network failure - Clean up timer in finally block to prevent memory leaks - Add comprehensive unit tests for all failure scenarios Fixes asyncapi#2027
🦋 Changeset detectedLatest commit: 46f3225 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 |
There was a problem hiding this comment.
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.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
|
Hi team! Just checking in — all CI checks are passing (including SonarCloud Quality Gate) and the PR is mergeable. Would appreciate a review when you get a chance. Happy to address any feedback. Thanks! |



Summary
AbortControllerwith 5-second timeout toregistryValidation()to prevent CLI from hanging indefinitely when--registry-urlpoints to an unreachable hostGETtoHEADfor lightweight registry reachability checkfinallyblock to prevent memory leaksRoot Cause
registryValidation()insrc/utils/generate/registry.tscalledfetch(registryUrl)without any timeout orAbortController. When targeting an unreachable host (e.g.,10.255.255.1), the TCP connection hangs indefinitely, blocking the CLI and stalling CI pipelines.Changes
src/utils/generate/registry.ts:AbortControllerwith 5s timeoutGET→HEAD(lighter validation, only checks reachability)finallyblock for timer cleanuptest/unit/utils/registry.test.ts(new):Test Plan
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --registry-url http://10.255.255.1now fails in ~5s with clear errorFixes #2027