Skip to content

fix: skip redundant AsyncAPI examples fetching during build (fixes #2015)#2162

Open
gavin913427-hash wants to merge 2 commits intoasyncapi:masterfrom
gavin913427-hash:fix/skip-redundant-fetch
Open

fix: skip redundant AsyncAPI examples fetching during build (fixes #2015)#2162
gavin913427-hash wants to merge 2 commits intoasyncapi:masterfrom
gavin913427-hash:fix/skip-redundant-fetch

Conversation

@gavin913427-hash
Copy link
Copy Markdown

What

Skip redundant AsyncAPI examples fetching during build when examples already exist.

Why

The scripts/fetch-asyncapi-example.js script was running on every build, even when examples already existed. This caused:

  • Slower build times (downloading ZIP + parsing YAML files)
  • Unnecessary network traffic
  • Flaky builds when GitHub is unreachable

How

  • Added a check to see if assets/examples/examples.json already exists
  • If it does, skip the entire fetch/unzip/parse workflow
  • To force a re-fetch, delete the assets/examples/ directory
  • Also made tidyUp() safe by checking if the ZIP file exists before deleting

Changes

File Change
scripts/fetch-asyncapi-example.js Add existence check before fetching examples

Testing

# First build: fetches examples
npm run build

# Second build: skips fetch (fast)
npm run build
# Output: "Examples already exist, skipping fetch. Delete assets/examples/ to force re-fetch."

# Force re-fetch
rm -rf assets/examples/
npm run build

Fixes #2015

The fetch-asyncapi-example.js script was running on every build, even
when examples already existed. This caused:
- Slower build times
- Unnecessary network traffic
- Flaky builds when GitHub is unreachable

Now the script checks if examples.json already exists before fetching.
To force a re-fetch, delete assets/examples/ directory.

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

changeset-bot Bot commented May 3, 2026

🦋 Changeset detected

Latest commit: 8e2c1bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Patch

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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 3, 2026

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] Optimizing build process: Skip redundant AsyncAPI examples fetching

1 participant