[BUG] Duplicate AsyncAPI specification loading in `fromTemplate.ts` command (unnecessary double parsing)

Open Beginner friendly
#2,017 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
cli, performance

Research direction

Start in src/apps/cli/commands/generate/fromTemplate.ts and trace the fromTemplate command around loadAsyncAPIInput(asyncapi) and load(asyncapi). Run the large-specification command described in the issue, checking the load calls and generation result. Done means the command performs one load and remains functionally identical.

Written by the indexing model from the issue text.

Description

bug stale
Describe the bug.

File: src/apps/cli/commands/generate/fromTemplate.ts
The fromTemplate command loads the AsyncAPI file twice during execution.

First via:

const asyncapiInput = await this.loadAsyncAPIInput(asyncapi);

Then again via:

specification = await load(asyncapi);

This results in:

  • Duplicate disk I/O
  • Duplicate parsing
  • Unnecessary memory usage
  • Slower execution for large specifications

The first loaded result is not reused, making the second load redundant.

This is a performance inefficiency in CLI command flow.

Expected behavior

The AsyncAPI file should be loaded and parsed only once during command execution.

  • The result of loadAsyncAPIInput(asyncapi) should be reused for generation.
  • The CLI should not call load(asyncapi) again.
  • There should be no duplicate disk reads or parsing steps.
  • Large AsyncAPI files should not incur unnecessary performance overhead.
  • Command execution should remain functionally identical but more efficient.
Screenshots
Image
How to Reproduce
  1. Create a large AsyncAPI file (e.g., with many channels and components).

2.Run:

time asyncapi generate fromTemplate large.yaml @asyncapi/html-template -o out

  1. Observe execution time.

  2. Add logging inside:

load(asyncapi)

You will see it is invoked after loadAsyncAPIInput() already processed the file.

🖥️ Device Information [optional]
  • Operating System (OS): Windows(WSL)
  • Browser:
  • Browser Version:
👀 Have you checked for similar open issues?
  • I checked and didn't find similar issue
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Dominant language
TypeScript
Stars
274
Forks
376
Avg merge
12h 11m
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from asyncapi/cli

All issues in asyncapi/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.