feat: Add redirect for mismatched node IDs#237
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CI/CD Status Update✅ All GitHub CI Checks Passing
❌ Vercel Deployment FailureThe Vercel deployment continues to fail despite:
Investigation:
Possible Causes:
Recommended Next Steps:
The PR code changes are correct and ready to merge once the Vercel deployment issue is resolved. 🤖 Generated with Claude Code |
PR Review Complete ✅SummaryAll code review tasks completed. The PR is ready for maintainer review. Status
Code QualityThe redirect implementation is correct and follows Next.js best practices:
Vercel Deployment IssueThe Vercel failure is not related to code quality:
Recommendation: A maintainer with Vercel dashboard access should check the deployment logs at the Vercel deployment URL to diagnose environment variable or infrastructure issues. Next StepsThe PR is ready for maintainer approval and merge once the Vercel deployment issue is resolved by someone with dashboard access. 🤖 Generated with Claude Code |
✅ All CI/CD Checks PassingAll checks are now passing after force pushing the rebased branch:
What was fixed:The local branch had been rebased on top of newer main commits (including the React Server Components CVE fix #239), while the remote branch still had the old commit hashes. Force pushing the rebased branch triggered a fresh Vercel deployment which succeeded. Deployment URL:https://vercel.com/comfyui/registry-web/PiZV6A7r2AiB2uwM9ZB8Nbeiqtda The PR is ready for review and merge. 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Pull request overview
Adds client-side redirect logic in NodeDetails to canonicalize node URLs when the backend returns a different node.id than the one present in the current route, covering both /nodes/[nodeId] and /publishers/[publisherId]/nodes/[nodeId].
Changes:
- Added a
useEffectto redirect whennode.iddiffers from the URLnodeId - Refactored existing publisherId mismatch redirect into a
useEffect(instead of inline redirect +return null) - Redirects to the canonical publisher/node path when on a publisher-scoped route
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // redirect to correct node ID if the responded node.id doesn't match the URL nodeId | ||
| // this handles cases where the node ID has changed or been normalized | ||
| React.useEffect(() => { | ||
| if (!router.isReady || !node?.id || !nodeId) return | ||
|
|
||
| const isNodeIdMismatchedBetweenURLandNode = node.id !== nodeId | ||
| if (isNodeIdMismatchedBetweenURLandNode) { | ||
| // if we're on /publishers/[publisherId]/nodes/[nodeId], redirect to the correct publisher and node ID | ||
| if (_publisherId) { | ||
| router.replace(`/publishers/${publisherId}/nodes/${node.id}`) | ||
| } else { | ||
| // if we're on /nodes/[nodeId], redirect to the correct node ID | ||
| router.replace(`/nodes/${node.id}`) | ||
| } | ||
| } |
There was a problem hiding this comment.
Redirects are now performed in useEffect without preventing render during the redirect. This means the UI can briefly render with the legacy nodeId (e.g. the install command uses nodeId, and handleClaimNode navigates to /nodes/${nodeId}/claim), allowing a user to copy/click stale IDs before the replace completes. Consider tracking an isRedirecting flag (nodeId mismatch and/or publisherId mismatch) and returning null/a spinner while redirecting, similar to the previous inline redirect behavior.
There was a problem hiding this comment.
Fixed in commit 591393a. Added isRedirecting = isNodeIdMismatched || isPublisherIdMismatched flag (line 226), merged into shouldShowLoading (line 227-228). The component renders a spinner while redirecting, preventing any stale IDs from being visible or interactable.
Copilot Review Fixes (commit 591393a)Both suggestions have been addressed: 1. Competing
2. Brief render with stale IDs (comment on line 205):
|
When the API responds with a node.id that differs from the nodeId in the URL, automatically redirect to the correct node ID. This handles cases where: - Node IDs have been changed or normalized - Old node ID URLs are accessed Follows the same pattern as the existing publisher ID redirect logic. Related: https://github.com/Comfy-Org/comfy-api/pull/701 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The redirect logic was previously running directly in the component body, which could cause issues with React's rendering and Next.js SSR/hydration. Moving it to useEffect ensures it only runs on the client side after mount. This should fix the Vercel deployment failure.
Add guards to ensure redirects only run on the client side after: - Router is ready - Required data (node, nodeId, etc.) is available This prevents potential issues during SSR/build time when router.query might be empty or router.isReady is false.
All CI checks passing. Local build successful. Retriggering Vercel deployment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…alls and brief stale render - Compute isNodeIdMismatched and isPublisherIdMismatched flags outside effects - Publisher ID redirect effect early-returns when node ID is also mismatched, letting the node ID effect own the single redirect and avoiding competing calls - Publisher ID redirect now uses canonical node.id instead of URL nodeId - Add isRedirecting to shouldShowLoading to prevent rendering stale IDs before the redirect fires (avoids user seeing/copying legacy node IDs) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| router.replace(`/publishers/${publisherId}/nodes/${node!.id}`); | ||
| }, [router, node, isPublisherIdMismatched, isNodeIdMismatched, publisherId]); | ||
|
|
There was a problem hiding this comment.
router.replace here uses node!.id, but isPublisherIdMismatched only checks !!node (not node?.id). Since the generated Node type has id?: string, this can produce a redirect to /publishers/<publisherId>/nodes/undefined if node.id is missing. Add an explicit node?.id guard (e.g., require it in isPublisherIdMismatched or early-return in the effect) before building the redirect URL.
There was a problem hiding this comment.
Fixed in commit 11731d1. Changed !!node to !!node?.id in isPublisherIdMismatched (line 264), matching the same guard pattern already used in isNodeIdMismatched. Now router.replace can only be called when node.id is a non-empty string, preventing a redirect to /publishers/.../nodes/undefined.
…/nodes/undefined The Node type has id?: string (optional), so checking !!node alone was insufficient. Changed to !!node?.id to match the isNodeIdMismatched guard and prevent router.replace from building a URL with an undefined segment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot please review |
Summary
Implementation Details
When fetching node details, if `node.id` from the API response doesn't match the `nodeId` from the URL, the page will automatically redirect to the correct node ID. This is similar to the existing publisher ID redirect logic.
Redirect Logic (consolidated, commit 2ac012a)
Use Cases
Related
Reference: https://github.com/Comfy-Org/comfy-api/pull/701
Test Plan
🤖 Generated with Claude Code