Comfy-Org / Comfy-Org/ComfyUI_frontend

Improve app.canvas null-safety in slot click handlers

Open
#7,083 0 comments 0 reactions 1 assignee Claimed by @DrJKL View on GitHub
area:nodes
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Background

During review of PR #7059, a potential runtime issue was identified in the click handlers within `useSlotLinkInteraction` composable.

## Problem

The `onClick` and `onDoubleClick` handlers in `src/renderer/extensions/vueNodes/composables/useSlotLinkInteraction.ts` currently use unsafe destructuring of `app.canvas`, which can throw a runtime error if `app.canvas` is temporarily undefined.

Additionally, these handlers are semantically input-specific but are currently exposed for both input and output slot types without guards.

## Desired Improvements

1. Guard against `app.canvas` being undefined by checking it exists before use (avoid destructuring)
2. Add type guards to ensure handlers only execute for input slots (`type !== 'input'` early return)
3. Ensure `augmentToCanvasPointerEvent` always receives a valid canvas reference

## References

- Original PR: #7059
- Review comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/7059#discussion_r2578860738
- Requested by: @DrJKL

## Context

This issue was deferred from PR #7059 which was approved despite this concern, to be addressed in a future PR.

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-7083-Improve-app-canvas-null-safety-in-slot-click-handlers-2bc6d73d365081b7b003d1a7b782a560) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.