fix: resolve external $refs from subdirectories, add registry timeout, and fix browserslist error#2092
Conversation
…, and fix browserslist error - Fix issue asyncapi#1839: Convert relative file paths to absolute paths in Specification.fromFile() to ensure external $refs are resolved from the correct base directory when AsyncAPI files are in subdirectories. - Fix issue asyncapi#2027: Add 5-second timeout to registry URL validation with AbortController, use HEAD request for lightweight checks, and provide better error messages for unreachable servers. - Fix issue asyncapi#1781: Set BROWSERSLIST_DISABLE_CACHE environment variable to prevent browserslist from incorrectly parsing pnpm shell wrapper scripts as config files. Bounty: AsyncAPI Bounty Program 2026-04 (Issue asyncapi#2039)
|
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.
|



Summary
This PR fixes three issues from the AsyncAPI Bounty Program 2026-04:
Issue #1839: External $refs from subdirectories not resolved correctly
Problem: When an AsyncAPI file is located in a subdirectory (e.g.,
./src/contract/asyncapi.yaml), relative$refreferences to external files were not being resolved correctly.Solution: Modified
Specification.fromFile()to convert relative file paths to absolute paths usingpath.resolve(). This ensures that the parser can correctly resolve relative$refreferences from the file's actual directory.Issue #2027: CLI hangs with unreachable registry URL
Problem: When using
--registry-urlwith an unreachable host, the CLI would hang indefinitely without any timeout or error message.Solution: Added a 5-second timeout using
AbortControllerto the registry URL validation. Also changed from GET to HEAD request for a more lightweight check and improved error messages to be more informative.Issue #1781: Browserslist error with pnpm
Problem: When using pnpm to generate documentation, browserslist would incorrectly parse shell wrapper scripts (created by pnpm in
node_modules/.bin/) as config files, causing errors likeUnknown browser query 'basedir=$(dirname "$(echo "$0"....Solution: Set
BROWSERSLIST_DISABLE_CACHE=1environment variable in the generator service to prevent browserslist from looking for config files in unexpected locations.Changes
src/domains/models/SpecificationFile.ts: Convert relative paths to absolute paths infromFile()src/utils/generate/registry.ts: Add timeout and improved error handling for registry validationsrc/domains/services/generator.service.ts: Disable browserslist cache to prevent pnpm-related errorsTesting
test/unit/utils/registry.test.tsfor registry validation teststest/unit/models/SpecificationFile.test.tsfor specification file path resolution testsFixes #1839, fixes #2027, fixes #1781
Bounty: AsyncAPI Bounty Program 2026-04 (Issue #2039)