Comfy-Org / Comfy-Org/ComfyUI_frontend

chore: useToolManager dead ref + unhandled rejections in async pointer handlers

Open
#11,500 0 comments 0 reactions 0 assignees View on GitHub
area:mask-editor developer experience
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Context

Surfaced during code review on #11409 (MMB detection refactor). These are **pre-existing issues** in `useToolManager.ts`, not introduced by #11409, but flagged while reviewing adjacent MMB handler branches. Filed separately to keep #11409 focused.

## Issue 1 — Dead reactive state: \`mouseDownPoint\`

**File**: \`src/composables/maskeditor/useToolManager.ts:35,230\`

\`mouseDownPoint\` is declared as a \`ref\` and only ever assigned \`null\` in \`handlePointerUp\`. It is never read by any consumer. Pure dead state.

**Fix**: Remove the \`ref\` declaration and its assignment.

## Issue 2 — Unhandled rejections in async pointer handlers

**File**: \`src/composables/maskeditor/useToolManager.ts:114-231\`

\`handlePointerDown\`, \`handlePointerMove\`, and \`handlePointerUp\` are \`async\` and awaited from DOM event listeners. They call into \`brushDrawing.startDrawing\`, \`handleDrawing\`, \`drawEnd\`, and \`panZoom.handlePanMove\`. A rejection from any of these becomes an **unhandled promise rejection** with no user feedback.

**Impact**: Mask editor tool errors (e.g., tainted canvas, OOM on large brush strokes) silently fail. User sees no toast, no log.

**Fix**: Wrap awaited calls in \`try/catch\` and route errors via \`useToastStore\` / \`toastErrorHandler\` from \`useErrorHandling\`.

## Acceptance criteria

- [ ] \`mouseDownPoint\` reference removed.
- [ ] At least one path (e.g., simulated \`brushDrawing.startDrawing\` throw) surfaces a user-visible toast instead of console unhandled rejection.
- [ ] Unit test coverage for the error-surfacing path.

## Related

- PR #11409 (review context)

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11500-chore-useToolManager-dead-ref-unhandled-rejections-in-async-pointer-handlers-3496d73d36508142a459c7d9dbafdad6) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Research direction

Start in src/composables/maskeditor/useToolManager.ts, reading the mouseDownPoint declaration and the handlePointerDown, handlePointerMove, and handlePointerUp paths. Check useErrorHandling and useToastStore for the existing error-reporting pattern, then add unit coverage for a rejected drawing call. Done means the dead ref is removed and at least one handler rejection produces a user-visible toast without an unhandled rejection.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.