Skip to content

Conversation

@snomiao
Copy link
Member

@snomiao snomiao commented Sep 9, 2025

Summary

This PR fixes a flaky test in the graph canvas menu that was intermittently failing in CI. The test was checking link visibility toggle functionality but wasn't properly waiting for the canvas to update after changing settings.

Problem

The test Can toggle link visibility was flaky because:

  1. It clicked the toggle button to change link visibility
  2. Only waited for one frame with nextFrame()
  3. Immediately took a screenshot for comparison

The issue was that changing the Comfy.LinkRenderMode setting triggers an async canvas redraw via setDirty(), but the actual redraw might not complete within a single frame.

Solution

Added proper synchronization:

  • Wait for setting to propagate: Use waitForFunction to wait until canvas.links_render_mode actually changes
  • Double frame wait: Call nextFrame() twice to ensure the canvas redraw completes
  • Timeout protection: Add 5-second timeout to prevent test hanging if something goes wrong

Testing

The fix ensures that:

  1. The setting change is confirmed at the canvas level (not just the store level)
  2. The canvas has time to complete its redraw cycle
  3. Screenshots are taken only after the visual state is stable

This should eliminate the race condition that was causing intermittent failures.

Related Code

The link visibility toggle is handled by:

  • Command: Comfy.Canvas.ToggleLinkVisibility in useCoreCommands.ts
  • Setting watcher: useLitegraphSettings.ts watches Comfy.LinkRenderMode and updates canvas
  • Canvas update: Calls canvas.setDirty(false, true) to trigger background redraw

Fixes the flaky test issue reported in CI.

┆Issue is synchronized with this Notion page by Unito

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

🎭 Playwright Test Results

⚠️ Tests passed with flaky tests

⏰ Completed at: 09/16/2025, 01:16:22 PM UTC

📈 Summary

  • Total Tests: 449
  • Passed: 419 ✅
  • Failed: 0
  • Flaky: 1 ⚠️
  • Skipped: 29 ⏭️

📊 Test Reports by Browser

  • chromium: View Report • ✅ 412 / ❌ 0 / ⚠️ 1 / ⏭️ 29
  • chromium-2x: View Report • ✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • chromium-0.5x: View Report • ✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0
  • mobile-chrome: View Report • ✅ 4 / ❌ 0 / ⚠️ 0 / ⏭️ 0

🎉 Click on the links above to view detailed test results for each browser configuration.

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

🔧 Auto-fixes Applied

This PR has been automatically updated to fix linting and formatting issues.

⚠️ Important: Your local branch is now behind. Run git pull before making additional changes to avoid conflicts.

Changes made:

  • ESLint auto-fixes
  • Prettier formatting

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

🔧 Auto-fixes Applied

This PR has been automatically updated to fix linting and formatting issues.

⚠️ Important: Your local branch is now behind. Run git pull before making additional changes to avoid conflicts.

Changes made:

  • ESLint auto-fixes
  • Prettier formatting

The test was flaky because it wasn't properly waiting for the canvas
to update after changing the link render mode setting. The setting
change triggers a canvas redraw via setDirty(), but the actual redraw
happens asynchronously.

Changes:
- Add explicit wait for canvas.links_render_mode to update
- Capture initial link render mode to properly verify state changes
- Add double frame wait plus 100ms delay to ensure canvas redraw completes
- Improve wait condition for visible links to handle undefined initial state
- Add timeout protection to prevent test hanging

This ensures the test reliably waits for both the setting change
and the visual update before taking screenshots, eliminating the
race condition that was causing intermittent failures.
The test was flaky because it wasn't properly waiting for the canvas
to update after changing the link render mode setting. The setting
change triggers a canvas redraw via setDirty(), but the actual redraw
happens asynchronously.

Changes:
- Add explicit wait for canvas.links_render_mode to update
- Capture initial link render mode to properly verify state changes
- Add double frame wait plus 100ms delay to ensure canvas redraw completes
- Improve wait condition for visible links to handle undefined initial state
- Add timeout protection to prevent test hanging

This ensures the test reliably waits for both the setting change
and the visual update before taking screenshots, eliminating the
race condition that was causing intermittent failures.
@snomiao snomiao force-pushed the sno-fix-flaky-toggle-link-visibility branch from f66afd7 to a6f3709 Compare September 9, 2025 06:20
snomiao and others added 4 commits September 10, 2025 07:32
…fy-Org/ComfyUI_frontend into sno-fix-flaky-toggle-link-visibility
Replace fixed delays with frame counter monitoring to ensure canvas
has completed rendering before taking screenshots. This eliminates
race conditions and makes the test more reliable.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@snomiao
Copy link
Member Author

snomiao commented Sep 11, 2025

problem prob solved by waiting for link_hidden status by page.evaluate but this impl is a bit too hacky.

@christian-byrne
Copy link
Contributor

This should be fixed on main now I think

@snomiao
Copy link
Member Author

snomiao commented Sep 22, 2025

close this PR as already fixed.

@snomiao snomiao closed this Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants