Skip to content

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

@sahillllllllll-bit

Description

@sahillllllllll-bit

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions