Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle HTML doc responses and skip blueprint fetch
  • Loading branch information
benceruleanlu committed Nov 28, 2025
commit a1a3a6420f794401736632126f17e1ce68423cac
34 changes: 18 additions & 16 deletions src/services/nodeHelpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,24 @@ class NodeHelpService {
locale: string
): Promise<string> {
const customNodeName = extractCustomNodeName(node.python_module)
let lastError: string | undefined
if (!customNodeName) {
throw new Error('Invalid custom node module')
}

// Try locale-specific path first
const localePath = `/extensions/${customNodeName}/docs/${node.name}/${locale}.md`
const localeDoc = await this.tryFetchMarkdown(localePath)
if (localeDoc) return localeDoc
if (localeDoc.text) return localeDoc.text
lastError = localeDoc.errorText

// Fall back to non-locale path
const fallbackPath = `/extensions/${customNodeName}/docs/${node.name}.md`
const fallbackDoc = await this.tryFetchMarkdown(fallbackPath)
if (fallbackDoc) return fallbackDoc
if (fallbackDoc.text) return fallbackDoc.text
lastError = fallbackDoc.errorText ?? lastError

throw new Error('Help not found')
throw new Error(lastError ?? 'Help not found')
}

private async fetchCoreNodeHelp(
Expand All @@ -46,35 +49,34 @@ class NodeHelpService {
): Promise<string> {
const mdUrl = `/docs/${node.name}/${locale}.md`
const doc = await this.tryFetchMarkdown(mdUrl)
if (!doc) {
throw new Error('Help not found')
if (!doc.text) {
throw new Error(doc.errorText ?? 'Help not found')
}

return doc
return doc.text
}

/**
* Fetch a markdown file and return its text, guarding against HTML/SPA fallbacks.
* Returns null when not OK or when the content looks like HTML.
* Returns null when not OK or when the content type indicates HTML.
*/
private async tryFetchMarkdown(path: string): Promise<string | null> {
private async tryFetchMarkdown(
path: string
): Promise<{ text: string | null; errorText?: string }> {
const res = await fetch(api.fileURL(path))

if (!res.ok) {
return null
return { text: null, errorText: res.statusText }
}

const contentType = res.headers.get('content-type') ?? ''
const contentType = res.headers?.get?.('content-type') ?? ''
const text = await res.text()

const looksHtml =
contentType.includes('text/html') ||
/^\s*<!doctype html/i.test(text) ||
/^\s*<html/i.test(text)
const isHtmlContentType = contentType.includes('text/html')

if (looksHtml) return null
if (isHtmlContentType) return { text: null, errorText: res.statusText }

return text
return { text }
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/workbench/utils/nodeHelpUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ export function extractCustomNodeName(

export function getNodeHelpBaseUrl(node: ComfyNodeDefImpl): string {
const nodeSource = getNodeSource(node.python_module)
if (nodeSource.type === NodeSourceType.Blueprint) {
return ''
}
if (nodeSource.type === NodeSourceType.CustomNodes) {
const customNodeName = extractCustomNodeName(node.python_module)
if (customNodeName) {
Expand Down
Loading