You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During the build process (npm run build), scripts/fetch-asyncapi-example.js unconditionally downloaded the examples ZIP file from GitHub, extracted it, and parsed every spec file to generate assets/examples/examples.json.
This network operation ran on every single build, causing:
Unnecessary network traffic and slower local build times.
Flaky builds if GitHub or the network was temporarily unreachable or offline even when examples were already present.
Root Cause
scripts/fetch-asyncapi-example.js executed immediately without verifying whether assets/examples/examples.json and the example YAML specs already existed in the local filesystem.
Solution
Added shouldSkipFetching() check to verify if assets/examples/examples.json exists, is non-empty, and example YAML files are present in the directory.
Added manual override support via --force, -f, or FORCE_FETCH_EXAMPLES=true environment variable so developers and CI can force re-fetching when needed.
Added unit tests in test/unit/scripts/fetch-asyncapi-example.test.ts covering all caching conditions, empty files, missing files, and forced overrides.
Testing
Added and ran unit test test/unit/scripts/fetch-asyncapi-example.test.ts (6 passing tests).
Verified node scripts/fetch-asyncapi-example.js skips when examples are present.
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
During the build process (
npm run build),scripts/fetch-asyncapi-example.jsunconditionally downloaded the examples ZIP file from GitHub, extracted it, and parsed every spec file to generateassets/examples/examples.json.This network operation ran on every single build, causing:
Root Cause
scripts/fetch-asyncapi-example.jsexecuted immediately without verifying whetherassets/examples/examples.jsonand the example YAML specs already existed in the local filesystem.Solution
shouldSkipFetching()check to verify ifassets/examples/examples.jsonexists, is non-empty, and example YAML files are present in the directory.--force,-f, orFORCE_FETCH_EXAMPLES=trueenvironment variable so developers and CI can force re-fetching when needed.test/unit/scripts/fetch-asyncapi-example.test.tscovering all caching conditions, empty files, missing files, and forced overrides.Testing
test/unit/scripts/fetch-asyncapi-example.test.ts(6 passing tests).node scripts/fetch-asyncapi-example.jsskips when examples are present.node scripts/fetch-asyncapi-example.js --forcedownloads fresh examples.npm run buildandnpm run lint.Risk
None. If
examples.jsondoes not exist or is invalid, the script falls back to downloading as before.Checklist
Fixes #2015