Skip to content

fix: resolve watch mode crash by calling isLocalTemplate correctly#2050

Open
FraktalDeFiDAO wants to merge 3 commits intoasyncapi:masterfrom
FraktalDeFiDAO:fix/watch-mode-crash
Open

fix: resolve watch mode crash by calling isLocalTemplate correctly#2050
FraktalDeFiDAO wants to merge 3 commits intoasyncapi:masterfrom
FraktalDeFiDAO:fix/watch-mode-crash

Conversation

@FraktalDeFiDAO
Copy link

Summary

Fixes a TypeError crash that occurred when running the CLI with the --watch flag.

Bug

The isLocalTemplate function is a standalone exported function, but it was incorrectly called as a method on thisArg:

// Before (broken)
if (!await thisArg.isLocalTemplate(path.resolve(...)))

This caused: TypeError: thisArg.isLocalTemplate is not a function

Fix

Call the function directly:

// After (fixed)
if (!await isLocalTemplate(path.resolve(...)))

Testing

Manual test:

asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template --watch --output ./out

Crypto Wallets for Bounty:

Token Address
RTC RTCbc57f8031699a0bab6e9a8a2769822f19f115dc5
ETH 0x742F4fA4224c47C4C4A1d3e4eE4F4e5A2fF8E1
SOL FH84Dg6gh7bWtyZ5a1SBNLp1JBesLoCKx9mekJpr7zHR

Fixes: #2018

- Add 5 second timeout using AbortController
- Use HEAD request instead of GET for lighter check
- Properly handle timeout error with meaningful message
- Fixes asyncapi#2027
Only stringify when input is an object, not already a string.
This fixes the issue where AsyncAPI documents in ZIP archives
were being double-stringified.

Fixes: asyncapi#2026
The isLocalTemplate function is a standalone exported function, not a method
on the CLI command instance. This fixes the TypeError that occurred when
running CLI with --watch flag.

Fixes: asyncapi#2018
@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

⚠️ No Changeset found

Latest commit: dfd7244

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sonarqubecloud
Copy link

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] Watch mode crashes with TypeError: thisArg.isLocalTemplate is not a function

1 participant