Compare commits

...

2 Commits

Author SHA1 Message Date
snomiao
e0153e72c2 [lint] Fix floating promises in browser_tests
- Fix floating promises in browser_tests/tests/remoteWidgets.spec.ts
- Fix floating promises in browser_tests/fixtures/ComfyPage.ts (4 methods)
- Fix floating promises in browser_tests/fixtures/components/SidebarTab.ts

All async functions now properly await their page.evaluate() calls to prevent floating promises.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 05:16:54 +00:00
snomiao
1a25695392 [lint] Enforce no-floating-promises ESLint rule
- Enable @typescript-eslint/no-floating-promises rule in eslint.config.js
- Fix floating promises in src/scripts/api.ts (setInterval with async callback)
- Fix floating promises in src/components/topbar/WorkflowTabPopover.vue (setTimeout with async callback)
- Fix floating promises in src/extensions/core/webcamCapture.ts (.then call)
- Fix floating promises in src/extensions/core/nodeTemplates.ts (.then call)
- Fix floating promises in src/composables/node/useNodeImage.ts (.then call)

All floating promises are now properly handled with void operator to explicitly indicate that the promise result is intentionally not being awaited.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 04:54:28 +00:00
8 changed files with 53 additions and 49 deletions

View File

@@ -1540,7 +1540,7 @@ export class ComfyPage {
}
async convertOffsetToCanvas(pos: [number, number]) {
return this.page.evaluate((pos) => {
return await this.page.evaluate((pos) => {
return window['app'].canvas.ds.convertOffsetToCanvas(pos)
}, pos)
}
@@ -1592,21 +1592,21 @@ export class ComfyPage {
await this.page.mouse.move(10, 10)
}
async getUndoQueueSize() {
return this.page.evaluate(() => {
return await this.page.evaluate(() => {
const workflow = (window['app'].extensionManager as WorkspaceStore)
.workflow.activeWorkflow
return workflow?.changeTracker.undoQueue.length
})
}
async getRedoQueueSize() {
return this.page.evaluate(() => {
return await this.page.evaluate(() => {
const workflow = (window['app'].extensionManager as WorkspaceStore)
.workflow.activeWorkflow
return workflow?.changeTracker.redoQueue.length
})
}
async isCurrentWorkflowModified() {
return this.page.evaluate(() => {
return await this.page.evaluate(() => {
return (window['app'].extensionManager as WorkspaceStore).workflow
.activeWorkflow?.isModified
})

View File

@@ -237,7 +237,7 @@ export class QueueSidebarTab extends SidebarTab {
if (width < 0 || width > 100) {
throw new Error('Width must be between 0 and 100')
}
return this.page.evaluate((width) => {
return await this.page.evaluate((width) => {
localStorage.setItem('queue', JSON.stringify([width, 100 - width]))
}, width)
}

View File

@@ -37,8 +37,8 @@ test.describe('Remote COMBO Widget', () => {
}, nodeName)
}
const clickRefreshButton = (comfyPage: ComfyPage, nodeName: string) => {
return comfyPage.page.evaluate((name) => {
const clickRefreshButton = async (comfyPage: ComfyPage, nodeName: string) => {
return await comfyPage.page.evaluate((name) => {
const node = window['app'].graph.nodes.find((node) => node.title === name)
const buttonWidget = node.widgets.find((w) => w.name === 'refresh')
return buttonWidget?.callback()

View File

@@ -94,40 +94,42 @@ const showPopover = (event: Event) => {
}
// Show popover after a short delay
showTimeout = setTimeout(async () => {
if (popoverRef.value && positionRef.value) {
popoverRef.value.show(event, positionRef.value)
await nextTick()
// PrimeVue has a bug where when the tabs are scrolled, it positions the element incorrectly
// Manually set the position to the middle of the tab and prevent it from going off the left/right edge
const el = document.querySelector(
`.workflow-popover-fade[data-popover-id="${id}"]`
) as HTMLElement
if (el) {
const middle = positionRef.value!.getBoundingClientRect().left
const popoverWidth = el.getBoundingClientRect().width
const halfWidth = popoverWidth / 2
let pos = middle - halfWidth
let shift = 0
showTimeout = setTimeout(() => {
void (async () => {
if (popoverRef.value && positionRef.value) {
popoverRef.value.show(event, positionRef.value)
await nextTick()
// PrimeVue has a bug where when the tabs are scrolled, it positions the element incorrectly
// Manually set the position to the middle of the tab and prevent it from going off the left/right edge
const el = document.querySelector(
`.workflow-popover-fade[data-popover-id="${id}"]`
) as HTMLElement
if (el) {
const middle = positionRef.value!.getBoundingClientRect().left
const popoverWidth = el.getBoundingClientRect().width
const halfWidth = popoverWidth / 2
let pos = middle - halfWidth
let shift = 0
// Calculate shift when clamping is needed
if (pos < 0) {
shift = pos - 8 // Negative shift to move arrow left
pos = 8
} else if (pos + popoverWidth > window.innerWidth) {
const newPos = window.innerWidth - popoverWidth - 16
shift = pos - newPos // Positive shift to move arrow right
pos = newPos
// Calculate shift when clamping is needed
if (pos < 0) {
shift = pos - 8 // Negative shift to move arrow left
pos = 8
} else if (pos + popoverWidth > window.innerWidth) {
const newPos = window.innerWidth - popoverWidth - 16
shift = pos - newPos // Positive shift to move arrow right
pos = newPos
}
if (shift + halfWidth < 0) {
shift = -halfWidth + 24
}
el.style.left = `${pos}px`
el.style.setProperty('--shift', `${shift}px`)
}
if (shift + halfWidth < 0) {
shift = -halfWidth + 24
}
el.style.left = `${pos}px`
el.style.setProperty('--shift', `${shift}px`)
}
}
})()
}, 200) // 200ms delay before showing
}

View File

@@ -72,7 +72,7 @@ const useNodePreview = <T extends MediaElement>(
if (options?.block) node.isLoading = true
loadElements(outputUrls)
void loadElements(outputUrls)
.then((elements) => {
const validElements = elements.filter(
(el): el is NonNullable<Awaited<T>> => el !== null

View File

@@ -39,7 +39,7 @@ class ManageTemplates extends ComfyDialog {
constructor() {
super()
this.load().then((v) => {
void this.load().then((v) => {
this.templates = v
})

View File

@@ -144,7 +144,7 @@ app.registerExtension({
}
// @ts-expect-error fixme ts strict error
node[WEBCAM_READY].then((v) => {
void node[WEBCAM_READY].then((v) => {
video = v
// If width isnt specified then use video output resolution
// @ts-expect-error fixme ts strict error

View File

@@ -384,14 +384,16 @@ export class ComfyApi extends EventTarget {
* Poll status for colab and other things that don't support websockets.
*/
#pollQueue() {
setInterval(async () => {
try {
const resp = await this.fetchApi('/prompt')
const status = (await resp.json()) as StatusWsMessageStatus
this.dispatchCustomEvent('status', status)
} catch (error) {
this.dispatchCustomEvent('status', null)
}
setInterval(() => {
void (async () => {
try {
const resp = await this.fetchApi('/prompt')
const status = (await resp.json()) as StatusWsMessageStatus
this.dispatchCustomEvent('status', status)
} catch (error) {
this.dispatchCustomEvent('status', null)
}
})()
}, 1000)
}