Skip to content

[BUG] Watch mode crashes with TypeError: thisArg.isLocalTemplate is not a function #2018

@sahillllllllll-bit

Description

@sahillllllllll-bit

Describe the bug.

When running the CLI with --watch, the process crashes immediately after initial generation with:

TypeError: thisArg.isLocalTemplate is not a function

The error occurs inside runWatchMode() in:

cli/src/utils/generate/watcher.ts

The function incorrectly calls:

thisArg.isLocalTemplate(...)

However, isLocalTemplate is a standalone exported function, not a method on the CLI command instance (thisArg). This results in an undefined function call and crashes watch mode.

Expected behavior

When running CLI with --watch:

  • Initial generation should complete successfully.
  • Watcher should start monitoring changes.
  • No runtime errors should occur.
  • The process should remain alive and continue watching for changes.

Screenshots

Image

How to Reproduce

  1. Run watch mode:
 asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --watch --output ./out
  1. Observe initial successful generation.

  2. After watcher starts, the CLI crashes with:

   TypeError: thisArg.isLocalTemplate is not a function

🖥️ 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

    Projects

    Status

    To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions