Skip to content

Conversation

@diegoimbert
Copy link
Contributor

No description provided.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 19, 2025

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 171d055
Status: ✅  Deploy successful!
Preview URL: https://962856d1.windmill.pages.dev
Branch Preview URL: https://di-inspect-suspendstatusval.windmill.pages.dev

View logs

@diegoimbert diegoimbert marked this pull request as ready for review November 19, 2025 15:58
@claude
Copy link
Contributor

claude bot commented Nov 19, 2025

Claude finished @diegoimbert's task —— View job


Reviewing PR #7179: inspect suspendValue

  • Read changed files and understand the context
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Provide detailed feedback

Summary

This PR adds a $inspect statement to debug a duplicate approval form issue in FlowPreviewResult.svelte. The change logs the suspendStatus.val entries to help track down when and why the approval form might be duplicated.

Review Feedback

⚠️ Issues to Address

1. Debug code should not be merged to main

The $inspect statement (lines 40-43) is a temporary debugging tool. According to the Svelte 5 documentation, $inspect is designed for development-only debugging and should be stripped from production builds.

However, committing debug code to the main branch is not a best practice because:

  • It clutters the codebase with temporary code
  • It can create confusion for other developers
  • It makes it harder to track when/if the debug code should be removed

Recommendation: Consider one of these alternatives:

  1. Create a separate development branch for debugging and don't merge until the issue is resolved
  2. Add a TODO comment with a ticket reference and timeline for removal
  3. Use conditional logging based on an environment variable if long-term debugging is needed

2. Comment alignment with code

The comment on line 39 // (See the #each below) refers to line 70 where suspendStatus.val is iterated. While helpful, it would be clearer to reference the specific purpose more directly.

✅ Positive Aspects

  1. Good documentation: The comments explain the purpose of the debug statement clearly
  2. Safe implementation: The || {} fallback on line 42 prevents null/undefined errors
  3. Proper Svelte 5 usage: $inspect is the correct modern rune for debugging reactive state

Code Quality

The code itself is well-written and follows Svelte 5 best practices. The use of $inspect with a descriptive label and transformed data (extracting job IDs) is appropriate for debugging.

Potential Bugs

No bugs introduced. However, if suspendStatus.val contains entries where v.job or v.job.id is undefined, the mapping on line 42 could cause issues. The current codebase assumes these are always present, which appears consistent with the type definition on line 17.

Performance Considerations

$inspect should be automatically stripped in production builds, so there's no production performance impact. During development, the logging overhead is minimal.

Security Implications

None - this is a debug logging statement that only logs job IDs.


Testing Instructions

To verify this change, run a flow preview that includes a suspend/approval step:

  1. Navigate to the Flows page in the Windmill app
  2. Create or open a flow that contains an Approval/Suspend step
  3. Run a preview of the flow
  4. When the flow reaches the suspend step, observe the browser's developer console (F12 → Console tab)
  5. You should see logs with the label 'suspendStatusVal' showing an array of [key, job_id] pairs for each suspended approval

The debug output helps identify if duplicate entries appear in the suspendStatus.val object, which would cause the approval form to be duplicated in the UI.


@diegoimbert diegoimbert marked this pull request as draft November 19, 2025 16:01
@diegoimbert diegoimbert marked this pull request as ready for review November 19, 2025 16:02
@claude
Copy link
Contributor

claude bot commented Nov 19, 2025

Claude finished @diegoimbert's task —— View job


Reviewing PR #7179: inspect suspendValue

  • Read changed files and understand the context
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Provide detailed feedback

Summary

This PR adds debug logging to investigate a duplicate approval form issue in FlowPreviewResult.svelte. The change logs suspendStatus.val entries to help identify when duplicates occur in the suspend status object.

Review Feedback

⚠️ Issues to Address

1. Using $effect with console.log instead of $inspect

The latest commit (171d055) changed from $inspect to $effect(() => console.log(...)) because $inspect doesn't work in production. However, this creates several problems:

  • Performance impact: Unlike $inspect which is stripped in production, console.log inside $effect will execute on every change in production
  • Unnecessary side effects: This adds console noise for all users, not just during debugging
  • Svelte 5 anti-pattern: $effect should be used for necessary side effects, not debugging

Recommendation: Consider these alternatives:

  1. Wrap in DEV check (if available in your build):
    $effect(() => {
      if (import.meta.env.DEV) {
        console.log('suspendStatusVal', ...)
      }
    })
  2. Use a feature flag or environment variable to enable debugging only when needed
  3. Keep using $inspect and debug in development mode where it works

2. Debug code in production codebase

Committing debug code to main is generally not recommended because:

  • It clutters the codebase with temporary code
  • Creates confusion about whether it should be removed
  • Adds runtime overhead in production

If this debugging is necessary, consider adding a TODO comment with a ticket reference and expected removal timeline.


✅ Positive Aspects

  1. Good documentation: The comments clearly explain the purpose and reference the relevant #each loop
  2. Safe implementation: The || {} fallback prevents null/undefined errors
  3. Focused logging: Only logs job IDs instead of full objects, keeping output manageable

Code Quality

The code structure is correct for Svelte 5, and the defensive programming with the || {} fallback is good practice.

Potential Bugs

If suspendStatus.val contains entries where v.job or v.job.id is undefined, the mapping could throw an error. However, based on the type definition on line 17 (Record<string, { job: Job; nb: number }>), these should always be present.

Performance Considerations

This is the main concern: Using $effect with console.log means this will run in production on every update to suspendStatus.val. For a component that may be rendered multiple times during flow execution, this could add noticeable overhead.

Security Implications

None - only job IDs are logged.


Testing Instructions

To verify this change, run a flow preview that includes a suspend/approval step. Navigate to the Flows page, create or open a flow with an Approval/Suspend step, and run a preview. When the flow reaches the suspend step, open the browser console (F12 → Console) and look for logs labeled 'suspendStatusVal' showing arrays of [key, job_id] pairs. The debug output helps identify if duplicate entries appear in the suspendStatus.val object.


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.

2 participants