[BUG] Duplicate AsyncAPI specification loading in `fromTemplate.ts` command (unnecessary double parsing)
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
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
How to Reproduce
- 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
-
Observe execution time.
-
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?
- I have 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from asyncapi/cli
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug stale
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug stale
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
🐞 docs bug stale
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug stale
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·